how to return query in codeigniter code example
Example 1: codeigniter get num_rows
$this->db->select('*');
$this->db->where('whatever');
$query = $this->db->get('table');
$num = $query->num_rows();
Example 2: codeigniter raw query
$sql="Select * from my_table where 1";
$query = $this->db->query($SQL);
return $query->result_array();
Example 3: get results from db and put in javascript array codeigniter
$query = $this->db->query("YOUR QUERY");
foreach ($query->result_array() as $row)
{
echo $row['title'];
echo $row['name'];
echo $row['body'];
}
Example 4: raw query in codeigniter
$query = $db->query('YOUR QUERY HERE');