Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Orm::find('all') not fetching results [1.6.1]
  • Hey guys, been using fuelphp for a while now with pretty good results, but i've started to work on a new project today and i'm trying to fetch results from a model with find('all') and it doesnt seems to work, am I missing some new configuration or something?

    I've created the model using oil, so i'd figure everything should be okay. Also, save() is working normally.

    Any ideas?
  • Try to replace the method "find" with the method "query", it should work. From the documentation:

    "When you use the find() method without properties, it will be considered to be an
    error situation. Currently it will return an Orm\Query object which you can use, and possibly
    reuse to find entries. This behaviour might change in the future, so using this is discouraged,
    use the query() method instead.
    "
  • That isnt working either, neither DB::query or DB::select, i'm really clueless here
  • Can you post your model code and implementation code of the method find() ?

  • Sure thing, here is the ViewModel i'm trying to fetch the results(it doesnt work on a Controller too):


    <?php

    class View_Experiencias_Inicio extends ViewModel
    {
    public function view()
    {
    $this->experiencias = Model_Entry::find('all');
    }
    }


    And this is the model:



    <?php

    class Model_Entry extends \Orm\Model
    {
    protected static $_properties = array(
    'id',
    'uid',
    'name',
    'description',
    'media',
    'created_at',
    'updated_at',
    );

    protected static $_observers = array(
    'Orm\Observer_CreatedAt' => array(
    'events' => array('before_insert'),
    'mysql_timestamp' => false,
    ),
    'Orm\Observer_UpdatedAt' => array(
    'events' => array('before_update'),
    'mysql_timestamp' => false,
    ),
    );
    protected static $_table_name = 'entries';


    public static function validate()
    {
    $val = Validation::forge();
    $val->add_field('name', 'Nome', 'required|min_length[1]|max_length[8192]');
    $val->add_field('description', 'Descrição', 'required|min_length[1]|max_length[8192]');
    $val->add_field('media', 'Midia', 'required|min_length[1]|max_length[555]');
    return $val;
    }

    }
  • ilNotturnoilNotturno
    Accepted Answer
    It seems correct, what error do you receive in your log files?
  • Oh, my bad it was a reference error, i was trying to access the object as an array like


    Html::img('/arquivos/thumb-'.$experiencias[0]->media)


    I suppose that worked someday for me, well anyway using a foreach I can see the results now. Thanks for the help!

Howdy, Stranger!

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

In this Discussion