Virtual Model Possible

Hi there,

i'am very new to Phalcon so i try to migrate a heavy website from old waterfallcode to Phalcon. The Site is running Postgresql with very custom querys using CTE's and ohter postgres only functions.

I created a "virtual" model for the result of such a huge query.

When i use the following code:

$item = new Item();

$result = new Simple($item->columnMap(), $item, $item->findById($id), $this->cache);

and following small sample from Item.php:

class Item extends \Phalcon\Mvc\Model
{
   public $id;
   public $user;

   public function columnMap()
   {
        return [
             'file_id'      => 'id',
             'file_user'     => 'user',
        ]
   }

   public function findById($id)
   {
        return $this->getDI()->get('db')->query($this->getBaseSql() . ' WHERE f.file_id = ?', [$id]);
   }
}

I have no Problems using the Model as long as i don't want to serialize / cache it via ->toArray() which lead to the following message:

Table 'item' doesn't exist in database when dumping meta-data for

So after study the documentation for ages, is there a way to get this scenario work?

edited May '16

I don't think it's a feasable scenario, because toArray needs metadata info from the model manager.

I'd try setting up views in pgsql, you can use them as read-only models.