IgnitedDatatables / Ignited-Datatables

Ignited Datatables is a wrapper class/library based on the native Datatables server-side implementation by Allan Jardine found at http://datatables.net/examples/data_sources/server_side.html for CodeIgniter
285 stars 335 forks source link

Can not Use mysql reserve words as column name in where condition [solution] #70

Open umefarooq opened 10 years ago

umefarooq commented 10 years ago

Hi, found one bug we can not use mysql reserve words as columns in where condition with Ignited Datatables as you are using simple string as where or condition and i used key as column name

$sWhere .= $this->select[$mColArray[$i]['data']] . " LIKE '%" . $sSearch . "%' OR ";

to avoid this problem and use mysql reserve words as column name use the following CI database function $this->ci->db->_protect_identifiers($col_name)

$this->ci->db->_protect_identifiers($this->select[$mColArray[$i]])

$sWhere .= $this->ci->db->_protect_identifiers($this->select[$mColArray[$i]['data']]) . " LIKE '%" . $sSearch . "%' OR "; line no 298

$sWhere .= $this->ci->db->_protect_identifiers($this->select[$mColArray[$i]]) . " LIKE '%" . $sSearch . "%' OR "; line no 300 in your current library