用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3174|回复: 6
收起左侧

关于query的一些问题.

[复制链接]
发表于 2009-2-10 01:19:15 | 显示全部楼层 |阅读模式
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');
 楼主| 发表于 2009-2-10 01:19:27 | 显示全部楼层
我用phpmyadmin插入没有问题.
发表于 2009-2-12 18:27:29 | 显示全部楼层
CI 一次只能写一条 sql 吧。
 楼主| 发表于 2009-2-13 07:20:24 | 显示全部楼层
这个让人很郁闷....
发表于 2009-2-13 10:03:05 | 显示全部楼层
一个循环和一次多条语句有本质区别吗?
发表于 2009-2-13 22:16:27 | 显示全部楼层
mysql区别应该不太大,支持事务的数据库就不一样了
发表于 2009-2-16 17:15:40 | 显示全部楼层
sql只能是一个语句。下面附上源码中的注释。
PHP复制代码
 
/**
 |       * 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.
 |       *
 |       * @access  public
 |       * @param   string  An SQL query string
 |       * @param   array   An array of binding data
 |       * @return  mixed      
 |       */

function query($sql, $binds = FALSE, $return_object = TRUE)
{
//...
}
复制代码

本版积分规则