[eluser]NateL[/eluser]
Very odd, I created my first function and this function works very well:
model: animal_model.php
Code:
function getAllAnimals()
{
$query = $this->db->get('available');
if ($query->num_rows() > 0 )
{
return $query->result();
}else{
show_error('Nothing in the database!');
}
}
However, inside my 'available' table, I have a visibility feature. 'visible' is on or off with a 1 or a 0
Code:
function getAvailableAnimals()
{
$query = $this->db->where('visible', 1);
//print_r($query);
if ($query->num_rows() > 0 )
{
return $query->result();
}else{
show_error('Nothing is currently available.');
}
}
in essence, returns "GET * WHERE visible = 1"
the function getAvailableAnimals() is essentially a copy/paste of getAllAnimals()
However, i'm this error:
Fatal error: Call to undefined method CI_DB_mysql_driver::num_rows() in
system_files/application/models/animal_model.php on line 26
Now, I've noticed my error, but I'm not quite sure how to fix it.
What I need it to say is "GET * FROM available WHERE visible = 1"
---
As I was typing out this message, realized I was not selecting my table named 'available'...I found a solution that I tested to work..but i'm wondering if there may be a better way to write this line?
$query = $this->db->get('available', $this->db->where('visible', 1));
Thanks