Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorbloogrox
    • CommentTimeNov 15th 2008
     
    Hi!
    i have model User, User $has_one Wallet
    code:
    $Wallet = $_User->wallet->find(); // i want to retrieve wallet object associated to user
    raises:
    Notice: Tried 'SELECT wallets.* FROM wallets LEFT OUTER JOIN users ON users.id = wallets.user_id WHERE wallets.user_id = '12' AND ( __owner.type = 'User' ) '. Got: [1054] Unknown column '__owner.type' in 'where clause' in C:\xampp\htdocs\showbirja\lib\AkActiveRecord\AkDbAdapter.php on line 226

    i copy paste this sql to sqlmanager and execute,
    without "AND ( __owner.type = 'User' )" it works fine

    is it bug?
    how could i get over it ?

    thnx!
    • CommentAuthorsuthern
    • CommentTimeNov 18th 2008 edited
     

    If each user has only one wallet, (Table user has 'wallet_id'), what about using $Wallet = $_User->wallet->load();

    • CommentAuthorbloogrox
    • CommentTimeNov 18th 2008
     
    and what if
    Table wallet has 'user_id', but
    table user doesn't have 'wallet_id'.
    • CommentAuthorsuthern
    • CommentTimeJun 22nd 2010
     

    BlooGrox, this thread is a couple of years old. Are you still around? Sorry I never saw your response.

    Putting the user_id inside the schema wallet is interesting. As long as you have defined your models correctly (Has_one and belongs_to), then

    $this->User->wallet->load();
    

    should work just fine.

Add your comments
    Username Password
  • Format comments as