fjctlzy 发表于 2009-2-10 01:19:15

关于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');

fjctlzy 发表于 2009-2-10 01:19:27

我用phpmyadmin插入没有问题.

Hex 发表于 2009-2-12 18:27:29

CI 一次只能写一条 sql 吧。

fjctlzy 发表于 2009-2-13 07:20:24

这个让人很郁闷....

Hex 发表于 2009-2-13 10:03:05

一个循环和一次多条语句有本质区别吗?

liugehao 发表于 2009-2-13 22:16:27

mysql区别应该不太大,支持事务的数据库就不一样了

neversaylate 发表于 2009-2-16 17:15:40

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]
查看完整版本: 关于query的一些问题.