Hi,
I am trying to write my sql statement in PHQL style but i am getting some errors. I have two Models called 'Media & MediaCategory' both extends from Phalcon Models. My sql statement works fine using raw sql format as below:
$rawSQL = "SELECT m.*, mc.cid FROM MediaCategory mc JOIN media m ON m.id = mc.id WHERE m.id = 1";
$result = $this->getModelsManager()->executeQuery($rawSQL);
But when i tring to convert it to PHQL format as follow i get this alias error "SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'm'"
$result =$this->getModelsManager()->createBuilder()
->columns(array('m.*', 'mc.cid'))
->from(array('mc' =>'MediaCategory'))
->addFrom('media')
->join('media', 'm.id = mc.id', 'm')
->where('m.id = 1')
->getQuery()
->execute();
Could you please help me?
Thanks