Subquery used as value parameter of CodeIgniter's where() call inappropriately wraps the subquery in single quotes
The code I am using in CodeIgniter is as follows:
$where_conditions = array();
$where_conditions['E_F_L.ei'] = $ei;
$where_conditions['E_F_L.esi <= '] = $esi;
$where_conditions['E_F_L.si'] = $si;
$where_conditions['E_P_L.P_I'] = $P_I;
$where_conditions['E_P_M.qualify_marks <= '] = "SELECT sumof3(F_T_M_P.ra , F_T_M_P.ma , F_T_M_P.mo)";
$clearing_year = $this->db
->select('E_F_L.ey,(F_T_M_P.ra + F_T_M_P.ma + F_T_M_P.mo) as mark',false)
->from('E_F_L')
->join('E_P_L', 'E_P_L.efi=E_F_L.efi', 'inner')
->join('E_P_M', 'E_P_M.P_I=E_P_L.P_I', 'inner')
->join('F_T_M_P', 'F_T_M_P.epi=E_P_L.epi', 'inner')
->where($where_conditions)
->order_by("F_T_M_P.tab_id", "desc")
->get();
It generates the code as follows:
SELECT E_F_L.ey, (F_T_M_P.ra + F_T_M_P.ma + F_T_M_P.mo) as mark
FROM (`E_F_L`)
INNER JOIN `E_P_L` ON `E_P_L`.`efi`=`E_F_L`.`efi`
INNER JOIN `E_P_M` ON `E_P_M`.`P_I`=`E_P_L`.`P_I`
INNER JOIN `F_T_M_P` ON `F_T_M_P`.`epi`=`E_P_L`.`epi`
WHERE `E_F_L`.`ei` = '18'
AND `E_F_L`.`esi` <= '113'
AND `E_F_L`.`si` = '12409'
AND `E_P_L`.`P_I` = '176'
AND `E_P_M`.`qualify_marks` <= 'SELECT sumof3(F_T_M_P.ra , F_T_M_P.ma , F_T_M_P.mo)'
ORDER BY `F_T_M_P`.`tab_id` desc
The required thing is:
SELECT E_F_L.ey, (F_T_M_P.ra + F_T_M_P.ma + F_T_M_P.mo) as mark
FROM (`E_F_L`)
INNER JOIN `E_P_L` ON `E_P_L`.`efi`=`E_F_L`.`efi`
INNER JOIN `E_P_M` ON `E_P_M`.`P_I`=`E_P_L`.`P_I`
INNER JOIN `F_T_M_P` ON `F_T_M_P`.`epi`=`E_P_L`.`epi`
WHERE `E_F_L`.`ei` = '18'
AND `E_F_L`.`esi` <= '113'
AND `E_F_L`.`si` = '12409'
AND `E_P_L`.`P_I` = '176'
AND `E_P_M`.`qualify_marks` <= (SELECT sumof3(F_T_M_P.ra , F_T_M_P.ma , F_T_M_P.mo))
ORDER BY `F_T_M_P`.`tab_id` desc
CI is inserting unwanted single quotes to query string in where statement near:
AND `E_P_M`.`qualify_marks` <= 'SELECT sumof3(F_T_M_P.ra , F_T_M_P.ma , F_T_M_P.mo)'
Is there any way to prevent it? I have tried using FALSE
$this->db->select('E_F_L.ey,(F_T_M_P.ra + F_T_M_P.ma + F_T_M_P.mo) as mark', false)