- find方法:
- findFirst方法,将返回
Phalcon\Mvc\Model\Criteria
对象 - Criteria方法 模型的
query()
将返回Phalcon\Mvc\Model\Criteria
对象$robots = Robots::query() ->where('type = :type:') ->andWhere('year < 2000') ->bind(['type' => 'mechanical']) ->limit(5, 10) ->orderBy('name') ->execute();
- PHQL
- Buider 是PHQL中的子功能
use Phalcon\Mvc\Model\Manager as ModelsManager; $builder = $this->modelsManager->createBuilder() ->columns('id, name') ->from('Robots') ->orderBy('name'); // Getting a whole set $robots = $this->modelsManager->createBuilder() ->from("Robots") ->join("RobotsParts") ->orderBy("Robots.name") ->getQuery() ->execute(); // Getting the first row $robots = $this->modelsManager->createBuilder() ->from("Robots") ->join("RobotsParts") ->orderBy("Robots.name") ->getQuery() ->getSingleResult();
相关博文
phalcon模型查询几种方法