gpt4 book ai didi

php - 如何检查 CodeIgniter 3.0.3 中的查询(删除、更新、选择、插入)?

转载 作者:行者123 更新时间:2023-11-28 23:39:39 25 4
gpt4 key购买 nike

我在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com