Welcome Guest, Not a member yet? Register   Sign In
DB_active_rec.php bug
#1

[eluser]Sam Dark[/eluser]
Mironoff reported this one in russian community forum. Confirmed on 1.6.2.

Code:
$this->db->from('text');
$this->db->join('link2tree','link2tree.link_text = text.id','left');
$this->db->where('link2tree.link_text IS NULL');
$this->db->where('text.trash',0);
$this->db->order_by('sort');
$this->db->get();

Gives us:

Code:
Error Number: 1109

Unknown table '000_link2tree.link_text00_text' in on clause

SELECT * FROM (`000_text`) LEFT JOIN `000_link2tree` ON 000_link2tree.link_text00_text.id WHERE 000_link2tree.link_text IS NULL AND 000_text.trash = 0 ORDER BY `sort`

It's in DB_active_rec.php:
Code:
// If a DB prefix is used we might need to add it to the column names
if ($this->dbprefix)
{
    $this->_track_aliases($table);

    // First we remove any existing prefixes in the condition to avoid duplicates
    $cond = preg_replace('|('.$this->dbprefix.')([\w\.]+)([\W\s]+)|', "$2$3", $cond);

    // Next we add the prefixes to the condition
    $cond = preg_replace('|([\w\.]+)([\W\s]+)(.+)|', $this->dbprefix . "$1$2" . $this->dbprefix . "$3", $cond);
}

And when changing

Code:
// Next we add the prefixes to the condition
$cond = preg_replace('|([\w\.]+)([\W\s]+)(.+)|', $this->dbprefix . "$1$2" . $this->dbprefix . "$3", $cond);

to

Code:
// Next we add the prefixes to the condition
$cond = preg_replace('|([\w\.]+)([\W\s]+)|', $this->dbprefix . "$1$2", $cond);

everything works.


Messages In This Thread
DB_active_rec.php bug - by El Forum - 05-22-2008, 10:22 AM
DB_active_rec.php bug - by El Forum - 05-23-2008, 05:13 AM
DB_active_rec.php bug - by El Forum - 05-24-2008, 05:14 AM
DB_active_rec.php bug - by El Forum - 05-24-2008, 05:25 AM
DB_active_rec.php bug - by El Forum - 05-24-2008, 05:26 AM
DB_active_rec.php bug - by El Forum - 05-24-2008, 05:43 AM
DB_active_rec.php bug - by El Forum - 05-24-2008, 07:12 AM
DB_active_rec.php bug - by El Forum - 05-24-2008, 07:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB