这是我的insert 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命令。尝试用单独的呼叫发送单独的LOCKSELECT等命令。

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

10-09 21:02