php代码点火器选择数据
我有一个在mysql工具中运行的查询命令php代码点火器选择数据,php,mysql,codeigniter,Php,Mysql,Codeigniter,我有一个在mysql工具中运行的查询命令 SELECT * FROM t_table1 WHERE id=18888 但当尝试在php codeigniter中执行此命令时,不返回任何行。 我尝试获取日志进程: $report = array(); $report['sql'] = $this->db->last_query(); $report['error'] = $this->db->_error_number(); $report['message'] = $t
SELECT * FROM t_table1 WHERE id=18888
但当尝试在php codeigniter中执行此命令时,不返回任何行。
我尝试获取日志进程:
$report = array();
$report['sql'] = $this->db->last_query();
$report['error'] = $this->db->_error_number();
$report['message'] = $this->db->_error_message();
$report['aff_row'] = $this->db->affected_rows();
print_r($report);
没有错误消息,但受影响的_行=0
但是这些行在一个函数中,有时是有效的,但当我试图更改数据库时,它将不起作用
请帮助..您正在从数据库中选择并检查受影响的行,而这不会给您计数。受影响的_行用于更新和删除命令 试用
$this->db->from('yourtable');
[... more active record code ...]
$query = $this->db->get();
$rowcount = $query->num_rows();
使用num_rows获取已获取的行数您可以尝试此操作
$this->db->select('*');
$this->db->where('whatever');
$query = $this->db->get('table');
$num = $query->num_rows();
尝试此查询,希望它有用
$result = $this->db->get_where('table_name',array('id'=>'1888'));
echo $result->num_rows();
试试这两行代码
$result = $this->db->where('id', 18888)->get(t_table1)->num_rows();
var_dump($result);
在控制器中:
$id=18888;
$this->data['get_results']=$this->your_name\u model->get_all\u by_id$id
在模型中:
public function get_all_by_id($id){
$this->db->select('*');
$this->db->from('t_table1');
$this->db->where('id',$id);
$query = $this->db->get();
return $query->result_array();
}
鉴于:
您也可以发布代码点火器活动查询。请显示您的查询代码。因为您没有任何受影响的行。。您正在使用选择查询。。。从数据库中获取数据而不进行任何更改。。。如果您使用任何查询,如update delete或对db进行了更改。。。你会麻木受影响的行。。