query codeigniter code example
Example 1: get result count codeigniter
public function record_count() {
return $this->db->count_all("tablename");
}
Example 2: ci db query error
$this->db->error();
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: query builder codeigniter
$this->db->set('name', $name);
$this->db->set('title', $title);
$this->db->set('status', $status);
$this->db->insert('mytable');