How to set an SQL alias for a Phalcon Model. A method alias() does not exist.
A sample of what i need:
$modelA = ModelA::query()
->alias('q')
->columns(['q.*','concat(q.id,r.id))
->join('ModelB', 'q.id = r.model_a_id', 'r', 'LEFT');
How can I create q alias?
Model query
returns \Phalcon\Mvc\Model\Criteria
. There is not method to set alias
.
You can get what are you trying with modelManager
as-
$modelA = $this->modelsManager->createBuilder()
->addFrom('ModelA', 'q')
->join('ModelB', 'a.id = r.model_a_id', 'r')
->columns(['q.*','concat(q.id,r.id))
->getQuery()
->execute();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With