gpt4 book ai didi

php - 前序遍历节点未在 codeigniter 中删除

转载 作者:行者123 更新时间:2023-11-29 14:21:22 25 4
gpt4 key购买 nike

我按照 sql 查询来删除节点。

$sql="LOCK TABLE xp_subunit WRITE; ";
$sql .= "SELECT @myLeft := ".$_GET['lft'].", @myRight := ".$_GET['rgt'].", @myWidth := ".$_GET['lft']." - lft + 1
FROM xp_subunit
WHERE id =".$_GET['id']."; ";

$sql .= "DELETE FROM xp_subunit WHERE lft BETWEEN @myLeft AND @myRight; ";

$sql .= "UPDATE xp_subunit SET rgt = rgt - @myWidth WHERE rgt > @myRight; ";
$sql .= "UPDATE xp_subunit SET lft = lft - @myWidth WHERE lft > @myRight; ";
$sql.="UNLOCK TABLES;";

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

我在 phpmyadmin 中尝试了此查询,它成功执行并根据需要删除节点。但是当我将其转换为 codeigniter 代码时,它会给出 mysql 语法错误,例如:

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 'DELETE FROM xp_subunit WHERE lft BETWEEN @myLeft AND @myRight;UPDATE xp_subunit ' at line 3

SELECT @myLeft := 1, @myRight := 29, @myWidth := 1 - lft + 1 FROM xp_subunit WHERE id =1; DELETE FROM xp_subunit WHERE lft BETWEEN @myLeft AND @myRight;UPDATE xp_subunit SET rgt = rgt - @myWidth WHERE rgt > @myRight;UPDATE xp_subunit SET lft = lft - @myWidth WHERE lft > @myRight;

我做错了什么吗...谢谢adv。

最佳答案

$this->db->query($sql) 旨在运行单个查询。

不支持在一次调用中进行多个查询。

关于php - 前序遍历节点未在 codeigniter 中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11699526/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com