这是我的插入 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 完美运行。"