Trouble with File 3.1.1 and SQL 4.x.x?
Hi all, I’m not the best with PHP or SQL but here’s my problem, and the solution I created.
I was having trouble with the newest iteration of this extension when using mySQL 4.1.13. After taking a look at the file I determined the cause of the issue. The SQL statement that updates the prefs table in the database is a newer piece of code that combines both the insert and update statements into one, allowing mySQL to check for a pre-existing table in the database instead of PHP. I don’t know of a way to combine these two queries into one, the way the Mark did, but its not like these queries will be called much anyway. The code change is below:
Replace the code on line 491:
$DB->query("INSERT INTO exp_mh_file VALUES('', {$id}, '{$key}', '{$value}') ON DUPLICATE KEY UPDATE id=values(id), `key`=values(`key`), value=values(value)");
—With the following—
$pref_results = $DB->query("SELECT * FROM exp_mh_file WHERE exp_mh_file.upload_id='{$id}' AND exp_mh_file.key='{$key}'");
if (!$pref_results) {
$DB->query("INSERT INTO exp_mh_file VALUES('', {$id}, '{$key}', '{$value}')");
}else{
$DB->query("UPDATE exp_mh_file SET exp_mh_file.value='{$value}' WHERE exp_mh_file.upload_id='{$id}' AND exp_mh_file.key='{$key}'");
}