Welcome Guest, Not a member yet? Register   Sign In
Access Database in Library
#1

[eluser]Morgan Cheng[/eluser]
In my understanding, CodeIgniter library can access database without any problem.

Code:
$ci =& get_instance();
$ci->db->select(...);

I happens to find some library accessing database through model. That is, this library should be installed together with given model files.

Is there any advantage to access database through model in library?
#2

[eluser]InsiteFX[/eluser]
Code:
// Create a private variable.
private $ci;    // for CodeIgniter Super Global Reference.

// In your Contructor add this.
$this->ci =& get_instance();    // get a reference to CodeIgniter.

// Then to access use this.
$query = $this->ci->db->get($table);

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB