这是我的疑问。
$this->db->where( 'user_id',$this->session->userdata('id'));
$this->db->from('votes');
$user_voted = $this->db->count_all_results();
我想从表中获取用户记录但是count_all_results();不计数表。任何人告诉我解决方案。如果我的查询不正确。
答案 0 :(得分:1)
$ this-> db-> count_all_results()在数据库调用中替换$ this-> db-> get()。
$this->db->select('id');
$this->db->from('table');
$this->db->where($your_conditions);
$num_results = $this->db->count_all_results();
对于实际查询(您应该已经拥有):
$this->db->select($your_columns);
$this->db->from('table');
$this->db->where($your_conditions);
$this->db->limit($limit);
$query = $this->db->get();
或者你可以试试这个:
$this->db->from(....);
$this->db->where(....);
$db_results = $this->get();
$results = $db_results->result();
$num_rows = $db_results->num_rows();
也可以尝试:
$id = $this->session->userdata('id');
$query = $this->db
->select(column one, column two)
->where('user_id',$id)
->get('votes');
$rowcount = $query->num_rows();
答案 1 :(得分:0)
试试这段代码
items: [
fileField,
new Ext.form.DateField({
xtype: 'datefield',
fieldLabel: 'Start date',
name: 'startdate',
format: 'd-m-Y'
}),
new Ext.form.DateField({
xtype: 'datefield',
fieldLabel: 'End date',
name: 'enddate',
format: 'd-m-Y'
}),
new Ext.form.ComboBox(selectStyleComboboxConfig)]
答案 2 :(得分:0)
行或计数的类似内容:
$id=$this->session->userdata('id');
// num rows example
$this->db->select('*');
$this->db->where('user_id',$id);
$query = $this->db->get('votes');
$num = $query->num_rows();
// here you can do something with $query
// count all example
$this->db->where('user_id',$id);
$num = $this->db->count_all_results('votes');
// here you only have $num, no $query