我在 codeigniter 2.0 中有一个项目,我使用了:
$query = $this->db->query('select * FROM my_table');
if($query->num_rows()==1) return true; else return false;
但是在 codeigniter 3.0.3 中我不知道如何检查(更新、选择、插入、删除...)。
最佳答案
用于插入、更新
$this->db->affected_rows();
Displays the number of affected rows, when
执行“写入”类型的查询(插入、更新等)。
if ( $this->db->affected_rows() > 0 )
{
return TRUE;
}
else
{
return FALSE;
}
选择
执行“选择”类型的查询(插入、更新等)。
if ($query->num_rows() > 0)
{
$dataSet = $query->result();
}
删除
$res = $this->a_model->delete_product($id); // example delete
if($res == FALSE)
{
}else
{
}
关于php - 如何检查 CodeIgniter 3.0.3 中的查询(删除、更新、选择、插入)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34740108/