1. find方法:
  2. findFirst方法,将返回 Phalcon\Mvc\Model\Criteria 对象
  3. Criteria方法 模型的query() 将返回 Phalcon\Mvc\Model\Criteria 对象
    $robots = Robots::query()
      ->where('type = :type:')
      ->andWhere('year < 2000')
      ->bind(['type' => 'mechanical'])
      ->limit(5, 10)
      ->orderBy('name')
      ->execute();
    
  4. PHQL
  5. 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模型查询几种方法
标签: