所以我正在使用一个非常旧的站点,客户不会让我将它升级到任何类型的 PDO。无论如何,我必须使用 mysql 查询,它真的开始让我沮丧。我似乎无法让它工作:
$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);
任何帮助将不胜感激。
更新:
这是错误消息:
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)