protect_identifiers issue in codeigniter 3.1.0

妖精的绣舞 提交于 2019-12-10 18:46:47

问题


In Previous version 2.2.6 i was using following code:

$this->db->_protect_identifiers=false;

$dataField='tm.*,IFNULL(CONCAT_WS(" " ,pm.firstName,pm.lastName),"") as assignedToName,IFNULL(cm.caseNo,"") as CaseNo,IFNULL(cm1.fileNo,"") as fileNo,IFNULL(sm.caseStage,"") as caseStage';

$qryTable='task_mst as tm 
            LEFT JOIN case_mst as cm on tm.caseNo=cm.ID
            LEFT JOIN case_mst as cm1 on tm.fileNo=cm1.ID
            LEFT JOIN party_mst as pm on tm.assignedTo=pm.ID
            LEFT JOIN session_mst as sm on tm.sessionId=sm.ID';
$task= $this->db->select($dataField,false)->from($qryTable)->where($where,NULL,FALSE)->order_by("ID","desc")->limit(10)->get()->result_array();

Now i am using Version 3.1.0 but "_protect_identifiers" will give error message

Fatal error: Cannot access protected property CI_DB_mysqli_driver::$_protect_identifiers

Can anyone tell me how to use "protect_identifiers()" in codeigniter 3.1.0?


回答1:


here is a sample

return 'SELECT '.$this->escape_identifiers('name')
            .' FROM '.$this->escape_identifiers('sysobjects')
            .' WHERE '.$this->escape_identifiers('type')." = 'U'";



回答2:


Try to set like this..

$this->db->protect_idenifiers(FALSE)->select(...)->where(...)

For more refer this.




回答3:


Simply remove the _ from the $this->db->_protect_identifiers. (Underscore Symbol)

$this->db->protect_identifiers=false;

This is the change CI made in new version.



来源:https://stackoverflow.com/questions/38874391/protect-identifiers-issue-in-codeigniter-3-1-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!