0

I have the following mysql query which I am running with php like so. Notice that the update query is updating multiple tables at the same time.

$sql1 = <<<TEST1
UPDATE catalog_topics a
LEFT JOIN catalog_files_join b ON a.catalogID = b.foreignKey
LEFT JOIN catalog_files_join c ON c.foreignKey = b.catalogFileID
LEFT JOIN catalog_files d ON d.catalogFileID = b.catalogFileID
LEFT JOIN catalog_lu_topics e ON a.topicID = e.topicID
SET d.catalogFileID = 'test1',
    b.catalogFileID = 'test1',
    c.foreignKey = 'test1'
WHERE b.fileTypeID = 'gvl401'
AND c.fileTypeID = 'gvl25'
AND e.parentID = 'top305'
AND a.sortorder =1
AND e.topicID = 'top312';
TEST1;
echo $sql1;
$returnVal = mysql_query($sql1);

I am seeing weird results if I run this query from php compared to when I run it directly in mysql. So I am wondering if there is some other way in php to handle queries that update multiple tables at same time?

Eventhough, the above query runs fine (because $returnVal is 1) ...I dont see all the records updated in the DB.

Is there a way in php to get back the number of records that got updated?

1 Answer 1

1

mysql_affected_rows() will return the amount of records that has been updated

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.