No MySQL will not define unique indexes without you telling it to do so via ALTER TABLE or CREATE TABLE statements.
Also, you're using a depreciated method of connecting to your database. Have you considered using PDO? It's more secure and fun! No need to use mysql_real_escape_string and it'll build on you OO knowledge
Sorry if I've missed anything:
try{
//get our database handle
$db = new PDO( 'mysql:dbname=testdb;host=127.0.0.1', 'Username', 'Password' );
//prepare our statament ready for values to be bound
$stmt = $db->prepare("
INSERT INTO `ecmt_memberlist` (
characterID,
name,
startDateTime,
baseID,
base,
title,
logonDateTime,
logoffDateTime,
locationID,
location,
shipTypeID,
shipType,
roles,
grantableRoles,
last_modified
) VALUES (
:characterID,
:name,
:startDateTime,
:baseID,
:base,
:title,
:logonDateTime,
:logoffDateTime,
:locationID,
:location,
:shipTypeID,
:shipType,
:roles,
:grantableRoles,
:modifiedTS
)
ON DUPLICATE KEY UPDATE
name = VALUE(name),
startDateTime = VALUE(startDateTime),
baseID = VALUE(baseID),
base = VALUE($base),
title = VALUE(title),
logonDateTime = VALUE(logonDateTime),
logoffDateTime = VALUE(logoffDateTime),
locationID = VALUE(locationID),
location = VALUE(location),
shipTypeID = VALUE(shipTypeID),
shipType = VALUE(shipType),
roles = VALUE(roles),
grantableRoles = VALUE(grantableRoles),
last_modified = VALUE(modifiedTS)
");
//create our object for binding
$ef = new stdClass();
$ef->characterID;
$ef->name;
$ef->baseID;
$ef->base;
$ef->title;
$ef->logonDateTime;
$ef->logoffDateTime;
$ef->locationID;
$ef->location;
$ef->locationID;
$ef->shipTypeID;
$ef->shipType;
$ef->roles;
$ef->grantableRoles;
//bind the params to the object properties
//the binding is done by reference so when the value of the property changes it will be retrieved when execute is called
$stmt->bindParam( ':characterID', $ef->characterID, PDO::PARAM_INT );
$stmt->bindParam( ':name', $ef->name, PDO::PARAM_STR );
$stmt->bindParam( ':baseID', $ef->baseID, PDO::PARAM_INT );
$stmt->bindParam( ':base', $ef->base, PDO::PARAM_STR );
$stmt->bindParam( ':title', $ef->title, PDO::PARAM_STR );
$stmt->bindParam( ':logonDateTime', $ef->logonDateTime, PDO::PARAM_STR );
$stmt->bindParam( ':logoffDateTime', $ef->logoffDateTime, PDO::PARAM_STR );
$stmt->bindParam( ':locationID', $ef->locationID, PDO::PARAM_INT );
$stmt->bindParam( ':location', $ef->location, PDO::PARAM_STR );
$stmt->bindParam( ':locationID', $ef->locationID, PDO::PARAM_INT );
$stmt->bindParam( ':shipTypeID', $ef->shipTypeID, PDO::PARAM_INT );
$stmt->bindParam( ':shipType', $ef->shipType, PDO::PARAM_INT );
$stmt->bindParam( ':roles', $ef->roles, PDO::PARAM_INT );
$stmt->bindParam( ':grantableRoles', $ef->grantableRoles, PDO::PARAM_INT );
//loop through our result set obtained via the API, I've left out the connection stuff
foreach ($xml->result->rowset[0] as $value){
//reassign the new set of variables
$ef = (object) $value;
//execute the query
$stmt->execute();
}
}catch( PDOException $e ){
echo $e->getMessage();
}
It's also worth mentioning that the above is trusting the api to return the correct fields. If you received more then clone the $ef object and reference it with property_exists.