Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Problem with find()
  • First off, I'd like to point out an error in the docs: On the ORM page under "find all", the example is:
    $entry = Model_Article::find('last', array(
        'where' => array('category_id', 1),
        'order_by' => array('date' => 'desc')
    ));
    

    This should in fact be:
    $entry = Model_Article::find('last', array(
        'where' => array('category_id' => 1),
        'order_by' => array('date' => 'desc')
    ));
    

    Now, onto my problem... I have the following code:
    $news = Model_Article::find($id, array('where' => array('type' => 'news')));
    

    I'm getting the following error:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NEWS ('id', '=', '1') LIMIT 1' at line 1 SELECT `t0`.`id` AS `t0_c0`, `t0`.`type` AS `t0_c1`, `t0`.`title` AS `t0_c2`, `t0`.`content` AS `t0_c3`, `t0`.`author_id` AS `t0_c4`, `t0`.`created_at` AS `t0_c5`, `t0`.`updated_at` AS `t0_c6`, `t0`.`published` AS `t0_c7`, `t0`.`published_at` AS `t0_c8`, `t0`.`furl` AS `t0_c9`, `t0`.`category_id` AS `t0_c10` FROM `articles` AS `t0` WHERE `t0`.`type` NEWS ('id', '=', '1') LIMIT 1

    Any ideas?
  • Problem is most likely caused because you're on RC2, RC3 should have been released already but our project lead has been very busy. A lot has been changed since RC2 and I updated the docs online a little bit too soon. You can probably solve this by moving to the develop branch, it's currently more stable than RC2 as there's no experimental code in there.
  • Thanks, that fixed the issue! The docs are still wrong, though ;)

Howdy, Stranger!

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

In this Discussion