So I am working with a very old site where the client wont let me upgrade it to any sort of PDO. Anyway I have to use mysql querys and its really starting to depress me. I cant seem to get this to work:
$array = array('1' => 1, '2' => 2);
$values = "({$array['1']}, 2, 'data3', 4, 5)";
if ($moreData){
$values = $values.", ({$array['6']}, 7, 'data8', 9, 10)";
}
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_reward ".
"('field1','field2','field3','field4','field5') ".
"VALUES ".$values);
Any help would be greatly appreciated.
UPDATE:
Here Is The Error Message:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''field1','field2','field3','field4','field5') VALUES (1, 2, 'data3' at line 1<br />Error No: 1064<br />INSERT INTO table ('field1','field2','field3','field4','field5') VALUES (1, 2, 'data3', 4, 5)
The field names in your query should not be within single quotes. They either need to have no quotes or be inside back-ticks.
You also need to make sure the field types match the data types as you are trying to enter in some integer values.