[eluser]Unknown[/eluser]
Hello All,
I am new to CI and I am facing a problem while using LIKE in my sql query.
function - 1 (This function will return all the rows according to my query and assign to an array.)
$this->db->select('all_spirit_id', 'current_stock')->from('tbl_allspirits')->where('current_stock', '0');
$query = $this->db->get();
foreach($query->result() as $row)
{
$namearray[] = $row;
}
Till now its good.
function - 2 (This function will check id form $namearray in another table and return the rows)
$this->db->select('*');
$this->db->from('mytable');
foreach($namearray as $cat)
{
$this->db->like('MyfieldName', $cat);
}
$result = $this->db->get()->result();
But this function is returnig all the rows(more than 100) and It should return the rows based on 'LIKE'(only 9 rows).
Getting below mentioned error with all the records.
-----------------------------------------------------------------------------
Severity: Warning
Message: mysql_real_escape_string() expects parameter 1 to be string, object given
Filename: mysql/mysql_driver.php
Line Number: 315