Welcome Guest, Not a member yet? Register   Sign In
Error to join table on active record method
#1

[eluser]kreamik[/eluser]
I try to join table of data

let's it be :

Code:
$this->db->select(fieldA,fieldB);
$this->db->join(
tableB,
"(tableB.fieldA = 'role_member' AND tableB.fieldB = tableA.fieldB) OR".
"(tableB.fieldA = 'group_member' AND tableB.fieldB = tableA.fieldB)",
"LEFT");
$r = $this->db->get(tableA);

it will generate
Code:
Select fieldA, fieldB
From tableA
LEFT JOIN tableB ON tableB.fieldA = 'role_member' AND tableB.fieldB = tableA.fieldB) OR (tableB.fieldA = 'group_member' AND tableB.fieldB = tableA.fieldB)

first sign "(" after ON conditiona always been removed in this line of code :
Code:
if (preg_match('/([\w\.]+)([\W\s]+)(.+)/', $cond, $match))
{
    $match[1] = $this->_protect_identifiers($match[1]);
    $match[3] = $this->_protect_identifiers($match[3]);

    $cond = $match[1].$match[2].$match[3];
}

on line : 331
function : public function join($table, $cond, $type = '')
file name : /system/database/DB_active_rec.php
CI version : 2.1.2




Theme © iAndrew 2016 - Forum software by © MyBB