j4mie / paris

A lightweight Active Record implementation for PHP5, built on top of Idiorm.
http://j4mie.github.com/idiormandparis/
996 stars 131 forks source link

ORM object instead of class object (extends Model). #117

Closed zaksmok closed 8 years ago

zaksmok commented 9 years ago

As written in docs I'm trying to create own model with custom methods:

class User extends Model  {
    public $email;

    public static $_table = 'users';

    public function roles() {
        return $this->has_many('Role');
    }

    public function full_name() {
        return $this->first_name . ' ' . $this->last_name;
    }

}

$user = User::findOne(1);
$user->full_name();

Result:

Fatal error: Uncaught exception 'IdiormMethodMissingException' with message 'Method full_name() does not exist in class ORM' in D:\xampp\htdocs\launch2.sm\Idiorm.php on line 2185
( ! ) IdiormMethodMissingException: Method full_name() does not exist in class ORM in D:\xampp\htdocs\launch2.sm\Idiorm.php on line 2185
treffynnon commented 9 years ago

Do you get the same error if you use the following?

$user = Model::factory('User')->find_one(1);
echo $user->full_name();
zaksmok commented 9 years ago

Yes. The same error

zaksmok commented 9 years ago

I double checked the code and i found that I caused that error. I was changing find_one() to findOne() in my controller files and by mistake i changed that function in Paris.php. Sorry for trouble, you can close ticket.