我在CodeIgniter中使用的代码如下:
$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();
它生成如下代码:
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
所需要的是:
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正在向where语句附近的查询字符串中插入不需要的单引号:
AND `E_P_M`.`qualify_marks` <= 'SELECT sumof3(F_T_M_P.ra , F_T_M_P.ma , F_T_M_P.mo)'
他们有什么方法可以阻止它吗?我尝试过使用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)