dbforge not loading |
[eluser]Bryan Zera[/eluser]
In my model, I load the dbforge class with Code: $this->load->dbforge(); Code: $fields = array( Code: Fatal error: Call to a member function on a non-object in /var/www/web2/modele/system/application/models/modele.php on line 51 Other forum postings suggest loading dbutil or making sure your driver is not the mysqli driver, but neither helped. Why won't dbforge load? MySQL Version: 5.0.32 CodeIgniter Version: 1.6.2 PHP Version: 4.4.2 (don't yell)
[eluser]AgentPhoenix[/eluser]
Have you tried moving the DB Forge stuff to a controller? I have an install script and I'm just doing all of the forge work right in the controller and it works beautifully.
[eluser]Bryan Zera[/eluser]
I can't/won't put it in a controller. My model is the entry point for the DB and I want to create tables on the fly.
[eluser]usmc[/eluser]
@Bryan Zera Is your database loaded prior to loading dbforge? Example (I know you don't have to load this way but it shows the database loading prior to dbforge) Code: class my_model extends Model {
[eluser]Bryan Zera[/eluser]
database is autoloaded. I have no problem with other DB-related functions.
[eluser]usmc[/eluser]
[quote author="Bryan Zera" date="1215554635"]In my model, I load the dbforge class with Code: $this->load->dbforge(); Code: $fields = array( Code: Fatal error: Call to a member function on a non-object in /var/www/web2/modele/system/application/models/modele.php on line 51 Other forum postings suggest loading dbutil or making sure your driver is not the mysqli driver, but neither helped. Why won't dbforge load? MySQL Version: 5.0.32 CodeIgniter Version: 1.6.2 PHP Version: 4.4.2 (don't yell)[/quote] Show it all baby I need to see your model in order to try and help.
[eluser]Bryan Zera[/eluser]
Modele.php: Lines 41-51 It's too big to post here and MIME'd too weird to attach to a PM or to this forum.
[eluser]usmc[/eluser]
Your problem stems from running init in the constructor and init then attempts to run a dbforge method. dbforge doesn't exist yet! Code: function Modele()
[eluser]Bryan Zera[/eluser]
I relented, put it in the controller and what do you know it works. Thanks all.
[eluser]caseyamcl[/eluser]
I found a dirty little trick for loading dbforge from within a model Just use $ci =& get_instance(); Not sure if this is on-par with CI techniques, but it worked for me in a pinch. Code: Class My_model extends Model() |
Welcome Guest, Not a member yet? Register Sign In |