php - 代码点火器插入语法错误

标签 php mysql codeigniter activerecord

这是我插入的sql语句:

$sql = "
                LOCK TABLE notre_offre WRITE;

                SELECT 
                    @myRight := rgt FROM notre_offre
                WHERE id = " . $this->input->post('category') . ";

                UPDATE notre_offre SET rgt = rgt + 2 WHERE rgt > @myRight;
                UPDATE notre_offre SET lft = lft + 2 WHERE lft > @myRight;
                INSERT INTO notre_offre(id, naziv, lft, rgt) VALUES(null, '" . $this->input->post('title') . "', @myRight + 1, @myRight + 2);
                UNLOCK TABLES;
                ";

        $query = $this->db->query($sql);

但是我遇到了语法错误:

"Error Number: 1064

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 'SELECT @myRight := rgt FROM notre_offre WHERE id = 2; UPD' at line 3

这是什么问题?这在 phpmyadmin 和 cmd 中完美运行。 "

最佳答案

不具体了解 Codeigniter,但您可能无法一次性发送多个 SQL 命令。尝试通过单独的 query() 调用发送单独的 LOCKSELECT 等命令。

关于php - 代码点火器插入语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14076987/

相关文章:

mysql - 不带别名删除

MySQL:跨2个表的唯一信息

c# - 像 selenium 这样的 headless 浏览器,但它不会打开实际的浏览器

PHP 只打印一行

php - laravel 项目部署到 Heroku 但缺少 Bootstrap 样式

php - 检查用户名是否存在,如果存在则生成新用户名 PHP

php - 如何定位数组中传递的列名来构造数据库查询

mysql - Codeigniter 查询在 MYSQL 中首先显示即将到来的 future 日期

php - 将 JavaScript 确认中的值传递给 Codeigniter Controller

codeigniter - 如何清理过期的 codeigniter session ?