I have "Pages" and "Widgets" which are in many-to-many relation. This is the Pages model definition:
namespace Acme\Models;
class Pages extends \Phalcon\Mvc\Model
{
public function initialize()
{
$this->hasManyToMany(
'id',
'Acme\Models\PagesWidgets',
'pages_id',
'widgets_id',
'Acme\Models\Widgets',
'id',
array('alias' => 'widgets')
);
}
}
I'm trying to access to the Widgets in resultset:
$result = $modelsManager->executeQuery('SELECT Acme\Models\Pages.*, Acme\Models\Widgets.* FROM Acme\Models\Pages JOIN Acme\Models\Widgets');
foreach($result as $row) {
echo $row->widgets->name;
}
But with no luck, because I've just got an error:
Notice: Undefined property: Phalcon\Mvc\Model\Row::$widgets
So, is there any way to do this?