1

ドキュメントで Phalcon\Mvc\Model\Criteria によってビルドされたクエリを取得する方法が見つかりませんでした: http://docs.phalconphp.com/en/latest/api/Phalcon_Mvc_Model_Criteria.html

出来ますか?

4

1 に答える 1

4

Phalcon\Mvc\Model\Criteria builds an array of valid parameters for SomeModel::find, or SomeModel::findFirst, this class does not build a real query.

Furthermore, we have Phalcon\Mvc\Query\Builder this class has the ability to build PHQL queries:

<?php

//Get the PHQL to be generated
$phql = $this->modelsManager->createBuilder()
    ->from('Robots')
    ->limit(20);
    ->order('Robots.name')
    ->getPhql();

//Execute the query
$robots = $this->modelsManager->createBuilder()
    ->from('Robots')
    ->limit(20);
    ->order('Robots.name')
    ->getQuery()
    ->execute();

More info: http://docs.phalconphp.com/en/latest/reference/phql.html#creating-queries-using-the-query-builder

于 2012-12-18T05:52:49.017 に答える