Welcome Guest, Not a member yet? Register   Sign In
How to fix a Num_row error
#10

Why do you use a "third party" database class instead of the built-in database library CI is providing? See https://www.codeigniter.com/userguide3/d...index.html
Just set up the connection paramaters in application/config/database.php and you're good to go.
Start using the query builder right away. It will save you a lot of time and trouble.

Simple example (meant as a function in a model):
PHP Code:
Public function get_products($category=NULL)
{
 
  $this->db
   
->select('id,product_name,category,price')
 
  ->from('products');
 
  If ($category) {
 
    $this->db->where('category'$category);
 
 }
 
 $this->db->order_by('product_name','ASC' );
 
 $query $this->db->get();
 
 If ($query->num_rows() > 0) {
 
    Return $query->result();
 
 }
 
 Else {
 
   Return FALSE;
 
 }

This function will return an array of records (if there are any), or FALSE if there are no records found.
Reply


Messages In This Thread
How to fix a Num_row error - by Mekaboo - 06-24-2019, 09:03 PM
RE: How to fix a Num_row error - by php_rocs - 06-24-2019, 09:59 PM
RE: How to fix a Num_row error - by Mekaboo - 06-25-2019, 11:19 AM
RE: How to fix a Num_row error - by neuron - 06-24-2019, 11:30 PM
RE: How to fix a Num_row error - by Mekaboo - 06-25-2019, 11:20 AM
RE: How to fix a Num_row error - by php_rocs - 06-25-2019, 03:49 PM
RE: How to fix a Num_row error - by Mekaboo - 06-25-2019, 08:02 PM
RE: How to fix a Num_row error - by php_rocs - 06-25-2019, 10:01 PM
RE: How to fix a Num_row error - by Mekaboo - 06-26-2019, 06:17 AM
RE: How to fix a Num_row error - by Wouter60 - 06-26-2019, 07:39 AM
RE: How to fix a Num_row error - by InsiteFX - 06-26-2019, 07:56 AM
RE: How to fix a Num_row error - by Mekaboo - 06-26-2019, 01:23 PM
RE: How to fix a Num_row error - by Mekaboo - 06-28-2019, 01:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB