I agree that this is a useful function to use when trying to check on whether an update query matched a particular row. I created a simple function that returns an associative array with the values delineated in the returned string.
function get_mysql_info($linkid = null){
$linkid? $strInfo = mysql_info($linkid) : $strInfo = mysql_info();
$return = array();
ereg("Records: ([0-9]*)", $strInfo, $records);
ereg("Duplicates: ([0-9]*)", $strInfo, $dupes);
ereg("Warnings: ([0-9]*)", $strInfo, $warnings);
ereg("Deleted: ([0-9]*)", $strInfo, $deleted);
ereg("Skipped: ([0-9]*)", $strInfo, $skipped);
ereg("Rows matched: ([0-9]*)", $strInfo, $rows_matched);
ereg("Changed: ([0-9]*)", $strInfo, $changed);
$return['records'] = $records[1];
$return['duplicates'] = $dupes[1];
$return['warnings'] = $warnings[1];
$return['deleted'] = $deleted[1];
$return['skipped'] = $skipped[1];
$return['rows_matched'] = $rows_matched[1];
$return['changed'] = $changed[1];
return $return;
}
After trying to update a row that may or may not exist, you can use the above function like so:
$vals = get_mysql_info($linkid);
if($vals['rows_matched'] == 0){
mysql_query("INSERT INTO table values('val1','val2', 'valetc')", $linkid);
}