• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Access CodeIgniter Database Class directly

#1
[eluser]ColonelChlorine[/eluser]
Does anyone have tips on how to access the CodeIgniter database classes/functions directly? I am working with PHPUnit and trying to test some of my classes that depend on

Code:
$CI =& get_instance();
$CI->db->query('blahblahblah');

It's not actually like that, because I use dependency injection to put the database into each class ... but in princple I need access to the fully instantiated class normally referenced by:

Code:
$this->db

I don't need the rest of the MVC framework, just the database functionality. I have tried things like requiring just the config/database.php file, and the system/database/DB.php, and working with that ... but it seems everything is so woven together I can't access the database without loading the entire framework. Gah!

Am I up !@#% creek? Looking forward to ideas/responses.

#2
[eluser]CroNiX[/eluser]
Have no idea if it works or not...it's also old but might point you in the right direction...
http://hasin.me/2007/06/13/using-activer...deigniter/

#3
[eluser]ColonelChlorine[/eluser]
Hi CroNiX, yeah I finally figured out something very similar to that. I would say that pretty much solves the issue. I was able to get it to work.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.