[eluser]thisischris[/eluser]
Hey guys, I'm pretty new to CG and have stumbled into my first bump.
I'm trying to use the database within a custom library.
I can only guess that it's because it's not extending the CI_Controller hence not available? What should I be doing?
I get the following error:
Fatal error: Call to a member function database() on a non-object in...
Which is:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User {
public function check_user_avail($string)
{
$this->load->database();
$query = $this->db->query("SELECT COUNT(*) FROM users WHERE username='$string'");
if ($query->num_rows() == 0)
{return TRUE;
}
else
{return FALSE;
}
}
}
/* End of file User.php */