public function count_all_results($table = '', $reset = TRUE)
{
if ($table !== '')
{
$this->_track_aliases($table);
$this->from($table);
}
$result = ($this->qb_distinct === TRUE)
? $this->query($this->_count_string.$this->protect_identifiers('numrows')."
FROM (
".$this->_compile_select()."
) CI_count_all_results")
: $this->query($this->_compile_select($this->_count_string.$this->protect_identifiers('numrows')));
if ($reset === TRUE)
{
$this->_reset_select();
}
if ($result->num_rows() === 0) // this is the line with the issue
{
return 0;
}
$row = $result->row();
return (int) $row->numrows;
}
Codeigniter Customers are complaining about the checkout on my site having issues submitting their order. When i check the error log, this is the error i see. How can i fix this
Below areas of the controller with the string count_all_results
$this->db->where('status','ok');
$this->db->where('featured','ok');
$this->db->where('added_by',json_encode(array('type'=>'vendor','id'=>$vendor_id)));
// pagination
$config['total_rows'] = $this->db->count_all_results('product');
$config['base_url'] = base_url() . 'index.php?home/listed/';
$config['per_page'] = 9;
$config['uri_segment'] = 5;
$config['cur_page_giv'] = $para2;
{ $this->load->library('Ajax_pagination');
$id= $this->session->userdata('user_id');
$this->db->where('from_where','{"type":"user","id":"'.$id.'"}');
$this->db->or_where('to_where','{"type":"user","id":"'.$id.'"}');
$config['total_rows'] = $this->db->count_all_results('ticket');
$config['base_url'] = base_url() . 'index.php/home/ticket_listed/';
$config['per_page'] = 5;
$config['uri_segment'] = 5;
$config['cur_page_giv'] = $para2;
{ $this->load->library('Ajax_pagination');
$id= $this->session->userdata('user_id');
$this->db->where('buyer', $id);
$config['total_rows'] = $this->db->count_all_results('sale');
$config['base_url'] = base_url() . 'index.php/home/order_listed/';
$config['per_page'] = 5;
$config['uri_segment'] = 5;
$config['cur_page_giv'] = $para2;
$function = "order_listed('0')";
$config['first_link'] = '«';
$config['first_tag_open'] = '<li><a rel="grow" class="btn-u btn-u-sea grow" onClick="' . $function . '">';
$config['first_tag_close'] = '</a></li>';
$rr = ($config['total_rows'] - 1) / $config['per_page'];
$last_start = floor($rr) * $config['per_page'];
$function = "order_listed('" . $last_start . "')";
$config['last_link'] = '»';
$config['last_tag_open'] = '<li><a rel="grow" class="btn-u btn-u-sea grow" onClick="' . $function . '">';
$config['last_tag_close'] = '</a></li>';
$function = "order_listed('" . ($para2 - $config['per_page']) . "')";
$config['prev_tag_open'] = '<li><a rel="grow" class="btn-u btn-u-sea grow" onClick="' . $function . '">';
$config['prev_tag_close'] = '</a></li>';
$function = "order_listed('" . ($para2 + $config['per_page']) . "')";
$config['next_link'] = '›';
$config['next_tag_open'] = '<li><a rel="grow" class="btn-u btn-u-sea grow" onClick="' . $function . '">';
$config['next_tag_close'] = '</a></li>';
$config['full_tag_open'] = '<ul class="pagination pagination-style-2 pagination-sm">';
$config['full_tag_close'] = '</ul>';
$config['cur_tag_open'] = '<li class="active"><a rel="grow" class="btn-u btn-u-red grow" class="active">';
$config['cur_tag_close'] = '</a></li>';
$function = "order_listed(((this.innerHTML-1)*" . $config['per_page'] . "))";
$config['num_tag_open'] = '<li><a rel="grow" class="btn-u btn-u-sea grow" onClick="' . $function . '">';
$config['num_tag_close'] = '</a></li>';
$this->ajax_pagination->initialize($config);
$this->db->where('buyer', $id);
$page_data['orders'] = $this->db->get('sale', $config['per_page'], $para2)->result_array();
$this->load->view('front/user/order_listed',$page_data);
}
{ $this->load->library('Ajax_pagination');
$id= $this->session->userdata('user_id');
$ids = json_decode($this->db->get_where('user',array('user_id'=>$id))->row()->wishlist,true);
$this->db->where_in('product_id', $ids);
$config['total_rows'] = $this->db->count_all_results('product');;
$config['base_url'] = base_url() . 'index.php/home/wish_listed/';
$config['per_page'] = 5;
$config['uri_segment'] = 5;
$config['cur_page_giv'] = $para2;
$function = "wish_listed('0')";
$config['first_link'] = '«';
$config['first_tag_open'] = '<li><a rel="grow" class="btn-u btn-u-sea grow" onClick="' . $function . '">';
$config['first_tag_close'] = '</a></li>';
$rr = ($config['total_rows'] - 1) / $config['per_page'];
$last_start = floor($rr) * $config['per_page'];
$function = "wish_listed('" . $last_start . "')";
$config['last_link'] = '»';
$config['last_tag_open'] = '<li><a rel="grow" class="btn-u btn-u-sea grow" onClick="' . $function . '">';
$config['last_tag_close'] = '</a></li>';
I have added areas of the controller that contain the string count_all_results i hope this helps
var = (condition x) ? y : z;
condition ? true : false;
in here where we have true "Y" and false "Z" is declared to var depending on condition. in your question the errors says operation is performed on Boolean
which means the Y or Z is returning Boolean
instead of value.
Please check the value declared by Y or Z and print them for batter debugging, there must be error in method you are calling or that method is returning Boolean
instead of Database Object
which is required for Code-igniter database library to perform operations.
Please edit your question and provide your code of methods for batter and accurate answer to your question.