Nimbuzz 77 Fri Sep 09 05:06:18 -0400 2011

Subject: Code Igniter and php.activerecord integration

Hello,
I tryied many tutorials, even that in this website:
http://matthewmachuga.com/post/4571278653/revised-php-activerecord-codeigniter-2-0-reactor
to use php.activerecord with CI.
I carried out all steps, but when I try to execute a query I get this error prom the PHP log file:
"Call to undefined method User::find() in /Users/.../application/controllers/user.php on line 10"

The mode extens the ActiveRecord/Model:
class User extends ActiveRecord\Model {
$table_name = 'users';
}

and, at line 10 I have this line:
$user = User::find(1);

Is this a known issue?
Does somebody know where I can find a good and tested tutorial?
Thank you


Clay vanSchalkwijk Sun Sep 11 17:53:38 -0400 2011

Can you do:

$user = new User;
var_dump($user);

I'm not sure if the CI autoloader is getting in the way and you're instantiating a different User class coming from somewhere else.

Nanne Huiges Tue Sep 13 03:55:15 -0400 2011

If it is an autoloader problem, you might want to put your ActiveRecord models in a seperate namespace. You would need to write your own autoloader (or manually add all the correct includes), but then you could actually specify something like

\ActiveRecordModels\User::find(1)

(1-2/2)