CodeIgniter Forums
Active Record bug? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Active Record bug? (/showthread.php?tid=24144)



Active Record bug? - El Forum - 11-01-2009

[eluser]Unknown[/eluser]
hello!

the code:
Code:
$query = $db->select('CONCAT( REPEAT( "---", ( COUNT(*)-1 )), c1.name )')
            ->from($this->_tableName . ' c1')
            ->join($this->_tableName . ' c2', 'c1.lft BETWEEN c2.lft AND c2.rgt', 'INNER')
            ->group_by('c1.name')
            ->order_by('c1.lft', 'ASC');

the error message:

A Database Error Occurred

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 '`BETWEEN` c2.lft AND c2.rgt GROUP BY `c1`.`name` ORDER BY `c1`.`lft` ASC' at line 3

SELECT CONCAT( REPEAT( "---", ( COUNT(*)-1 )), `c1`.`name` ) FROM (`categories` c1) INNER JOIN `categories` c2 ON `c1`.`lft` `BETWEEN` c2.lft AND c2.rgt GROUP BY `c1`.`name` ORDER BY `c1`.`lft` ASC

any ideas to solve this problem. Between gets quoted, and i don't know why.

thx for your help.