I'm rewriting my application to make use of CodeIgniter. Currently I'm struggling with DB. I've configured databases in config/databases.php
but have no idea how to access them at a library level.
I'm loading libraries via autoload.php
:
$autoload['libraries'] = array('database', 'FGMembersite', 'phpmailer', 'formvalidator');
FGMembersite is a class which I'm using for registration and login.
I access this class in login.php
view where I have:
if(isset($_POST['submitted']))
{
if($this->fgmembersite->Login())
{
$this->fgmembersite->RedirectToURL("main");
}
}
fgmembersite->Login()
leads to:
public function DBLogin()
{
$this->connection = pg_connect("host=localhost port=5432 dbname=".$this->db->database." user=".$this->ci->db->username." password=".$this->db->password."");
but DBLogin()
here doesn't understand what is db
. I receive errors like
Undefined property: FGMembersite::$db
or
Trying to get property of non-object
How I'm supposed to access database config in my FGMembersite
?