Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Empty ORM object properties after ->find('first')
  • I try configure FuelPHP with Orm support for users table. I create model like this:
    class Model_User extends Orm\Model {}
    

    Then in my controller:
    $user = new Model_User;
    $user->find(13);
    print $user->login; //email, pass, ...
    
    The above code displays blank page.
    I have one record in my users table with id=13. In profiler on database tab show 2 queries:
    SHOW FULL COLUMNS FROM `www_users`
    Speed: 5.896 ms
    SELECT `www_t0`.`id` AS `t0_c0`, `www_t0`.`login` AS `t0_c1`, `www_t0`.`pass` AS `t0_c2`, `www_t0`.`email` AS `t0_c3`, `www_t0`.`last_log` AS `t0_c4`, `www_t0`.`cart` AS `t0_c5`, `www_t0`.`prawa` AS `t0_c6` FROM `www_users` AS `www_t0` WHERE `www_t0`.`id` = 13 LIMIT 1
    Possible keys: PRIMARY ·Type: system ·Rows: 1 ·Speed: 0.937 ms
    

    This is definitely a stupid mistake, but I can't find it.
  • Moved to the ORM forum.
  • Pawe? Gruchociak wrote on Sunday 8th of January 2012:
    Then in my controller:
    $user = new Model_User;
    $user->find(13);
    print $user->login; //email, pass, ...
    

    Not really sure where you got the idea that would work, it's not documented usage. This is how you fetch:
    $user = Model_User::find(13);
    

    What you did is the equivalent of this:
    $user = new Model_User();
    Model_User::find(13); // note that the output of this isn't being assigned to anything
    echo $user->login;
    

    The find method is static, thus it won't care if it's called staticly or upon an object - it's always static and won't act upon the object on which you called it.
  • Oh my god. I wonder sometimes myself.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion