关于query的一些问题.
sql = "INSERT INTO event_term (EventID,Term,Count,Weight) VALUES('1','酒','7','1006');INSERT INTO event_term (EventID,Term,Count,Weight)VALUES ('1','酒吧','11','1010');
INSERT INTO event_term(EventID,Term,Count,Weight) VALUES ('1','精彩','2','1001');"
这段string用$this->db->query($sql); 提示
A Database Error Occurred Error Number: 1064
Youhave an error in your SQL syntax; check the manual that corresponds toyour MySQL server version for the right syntax to use near 'INSERT INTOevent_term (EventID,Term,Count,Weight) VALUES ('1','酒吧','11','10' atline 1
INSERT INTO event_term (EventID,Term,Count,Weight) VALUES('1','酒','7','1006');INSERT INTO event_term (EventID,Term,Count,Weight)VALUES ('1','酒吧','11','1010');INSERT INTO event_term(EventID,Term,Count,Weight) VALUES ('1','精彩','2','1001'); 我用phpmyadmin插入没有问题. CI 一次只能写一条 sql 吧。 这个让人很郁闷.... 一个循环和一次多条语句有本质区别吗? mysql区别应该不太大,支持事务的数据库就不一样了 sql只能是一个语句。下面附上源码中的注释。
/**
| * Execute the query
| *
| * Accepts an SQL string as input and returns a result object upon
| * successful execution of a "read" type query.Returns boolean TRUE
| * upon successful execution of a "write" type query. Returns boolean
| * FALSE upon failure, and if the $db_debug variable is set to TRUE
| * will raise an error.
| *
| * @accesspublic
| * @param stringAn SQL query string
| * @param array An array of binding data
| * @returnmixed
| */
function query($sql, $binds = FALSE, $return_object = TRUE)
{
//...
}
页:
[1]