I'm trying to wrap my head around this and I can't seem to figure out how this query returns a syntax error. My knowlegde of mySQL is small as I'm just getting to grips with it.
This is the query I'm trying to execute:
function _delete_leaf_node($id){
$query ="";
$query .=" SELECT @myLeft := lft, @myRight := rgt, @myWidth := rgt - lft + 1";
$query .=" FROM pages";
$query .=" WHERE id =".$id.";";
$query .=" DELETE FROM pages WHERE lft BETWEEN @myLeft AND @myRight;";
$query .=" UPDATE pages SET rgt = rgt - @myWidth WHERE rgt > @myRight;";
$query .=" UPDATE pages SET lft = lft - @myWidth WHERE lft > @myRight;";
$this->_custom_query($query);
}
This is the error I get returned:
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 pages WHERE lft = @myLeft UPDATE pages SET rgt = rgt + 1, lft = lft ' at line 1
I have checked if the right id is passed. Perhaps the variables are not set in the proper manner? I just don't know how one would check for that.
Any help would be greatly appreciated.