codigniter query code example
Example 1: codeigniter count rows
$this->db
->where(['field'=>'foo'])
->from("tablename")
->count_all_results();
//OR
$this->db
->where(['field'=>'foo'])
->count_all_results("tablename");
Example 2: 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'];
}