We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Query Alias

i'm using the Phalcon's ::query() criteria and how can i use aliases ?

edited Jan '17
 $mm = $this->modelsManager->createBuilder()
                'article_type_name' => 'typ.article_type_name',
            ->from(['vat' => 'm:ArticleVat', 'typ' => 'm:ArticleType']) //using implicit join with model namespace alias
            ->where('vat.article_type_id = typ.article_type_id')
            ->orderBy('vat.article_type_id') //DESC

        $data = $mm->execute();

// Services definition
$di->setShared('modelsManager', function() {
    $mm = new \Phalcon\Mvc\Model\Manager();
    //Registers shorter aliases for namespaces in PHQL statements
    //public registerNamespaceAlias (mixed $alias, mixed $namespaceName)
    $mm->registerNamespaceAlias('m', __NAMESPACE__ . '\Models');
    return $mm;