Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
relation issue, Unknown column
  • K so I'm trying to get the characters the logged users owns by writing the following:
    $characters_owned = Model_Character::find()
       ->where('user_id', $this->user_id)

    But this is the error I get:
    1054! Fuel\Core\Database_Exception [ 1054 ]: Unknown column 't0.user_id' in 'where clause' [ SELECT `t0`.`id` AS `t0_c0`, `t0`.`character_id` AS `t0_c1`, `t0`.`character_name` AS `t0_c2`, `t0`.`is_public` AS `t0_c3`, `t0`.`api_id_id` AS `t0_c4`, `t1`.`id` AS `t1_c0`, `t1`.`api_id` AS `t1_c1`, `t1`.`api_key` AS `t1_c2`, `t1`.`user_id` AS `t1_c3` FROM `simpleusers_characters` AS `t0` LEFT JOIN `simpleusers_api` AS `t1` ON (`t0`.`api_id_id` = `t1`.`api_id`) WHERE `t0`.`user_id` = 25 ]

    Here are my models
  • K so apparently the update didn't change any issue.
    But what I did however find was that 'simpleusers_api' isn't reconised cause of the alias 't1'.
    If I change simpleusers_api to t1 it works however. How come? fyi: the aliases are done automaticly.
  • Let me first quote myself:
    Ah, you're on RC2 aren't you? This is only supported in the latest dev branch.

    RC2 doesn't support this yet, this was added very recently and will be in RC3 which should be released very soon. (final is still a bit off as a lot of Unit tests still need to be written)
  • Oh sorry,
    I thought you were reffering to RC2 with the dev branch... I'm not quite familiar with names and versions :D So dev branch means still in development?
    what does RC stands for then? r=release? c=?
  • Does the characters table have a column with name 'user_id'? If not why would you expect your where condition to work?
    I can't check your models because Scrapyrd is timing out right now. But judging from the query user_id is part of the simpleusers_api table. And you should request it from that table by prepending the relation name and a dot. Check the docs for examples on how that can be done.
  • Oh well forgot to update my message, but I did however written
    $characters_owned = Model_Character::find()
       ->where('simpleusers_api.user_id', $this->user_id)

    But still gives about the same problem
  • Could you give it anyway, because it can't be exactly the same... there is some subtle difference this should cause.
  • This is the index:
    public function action_index()
      $characters_owned = Model_Character::find()
       ->where('simpleusers_api.user_id', $this->user_id)
      // $characters_permitted = Model_Character::find();
      $characters = Model_Character::find()->where('is_public', '=', 1)->order_by('character_name', 'asc')->get();
            $this->template->title = 'Characters list';
            $this->template->content = View::factory('characters/index')
       ->set('characters_owned', $characters_owned)
       // ->set('characters_permitted', $characters_permitted)
       ->set('characters', $characters);

    As of now the scrap website works... So you can find the related models.
  • I meant the error message
  • Ah, you're on RC2 aren't you? This is only supported in the latest dev branch.
  • To be honest I'm not sure on what I'm now. I can only find RC1 on the website.
    Fyi it might be usefull to put a download link. So what do I need to do? update to ?

Howdy, Stranger!

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

In this Discussion