Php 选中$this->;db->;get()是否为空
我正在使用Php 选中$this->;db->;get()是否为空,php,codeigniter,Php,Codeigniter,我正在使用codeigniter框架 如何检查get函数是否为空 ... $result = $this->db->get() //how to check $result is empty or not ? 你可以这样做 $query = $this->db->get(); if ($query->num_rows() > 0) { //record exists - hence fetch the row $res
codeigniter
框架
如何检查get
函数是否为空
...
$result = $this->db->get()
//how to check $result is empty or not ?
你可以这样做
$query = $this->db->get();
if ($query->num_rows() > 0) {
//record exists - hence fetch the row
$result = $query->row();
}
else
{
//Record do not exists
}
你可以像下面这样检查
$result = $this->db->get() ;
if($result->num_rows() != 0){
//you can do anything with data here
}
else{
//empty
}
根据 现在检查$result值是否为空
if(!empty($result)){
//code if not empty
}
else{
//code if empty
}
您可以使用
if($result->num_rows())
通常需要一些解释
$result = $this->db->get()->result_array();
if(!empty($result)){
//code if not empty
}
else{
//code if empty
}
$result = $this->db->get('myTable')->result();
print_r($result);die();