Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
DB problem
  •  
     I'm trying to get a db result as object
    DB::select()->from('table')->as_object('Model_Name')->execute();

     Return is a 
    Fuel\Core\Database_MySQLi_Result instance

     as_object() doest work anymore?
    any alternatives (without model_crud)
  • Yes, it does, but you're looking at the wrong thing.

    Database results are always returned as a result instance, which is a container object that contains the resultset. Only when you access the individual results the data is converted to the format you request, in this case Model_Name objects.

    $resultset = DB::select()->from('table')->as_object('Model_Name')->execute();
    foreach ($resultset as $result)
    {
        var_dump($result); // will dump Model_Name objects
    }

Howdy, Stranger!

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

In this Discussion