如何将查询转换为codeigniter命令?

时间:2014-09-16 09:29:41

标签: codeigniter

模型:

$query = $this->db->query("SELECT count(*) as c from event where id=48 and Ev_id=352");

if($query == 0){
   $act = array(
   'ev_id' => $ev_id,
   'id'   =>  $id ,
   'count' => '1'
);
//print_r($act);
$this->db->insert('join()', $act);

 }
else{
     echo"Unable to join";

1 个答案:

答案 0 :(得分:0)

根据manual

你应该使用

if ($query->num_rows() > 0)

插入是这样的:

$data = array(
               'title' => $title,
               'name' => $name,
               'date' => $date
            );

$this->db->insert('mytable', $data);