/**
  * @param string $fullUrl Full url.
  * @param array $params
  * @return \Phalcon\Mvc\Model\Query
  */
 public static function buildQuery($fullUrl, array $params = array())
 {
     /**
      * @var \Phalcon\Di $di
      */
     global $di;
     /**
      * @var \Phalcon\Mvc\Model $modelName
      */
     $modelName = Text::camelize(Text::uncamelize(Analyzer::getModelName($fullUrl)));
     $builder = new Builder();
     $builder->setDI($di);
     $builder->from($modelName);
     self::setColumns($builder, $params);
     $prepareUrl = self::getPrepareUrlOperators($fullUrl);
     $whereSql = self::buildWhere($prepareUrl);
     $whereSqlReplacement = Macros::replace($whereSql, $params, $modelName);
     $builder->where($whereSqlReplacement);
     $builder = self::limit($builder, $params);
     $builder = self::orderBy($builder, $params);
     $params = new Params($fullUrl, $params);
     $params = $params->getPrepareParams();
     $query = $builder->getQuery();
     $query->setBindParams($params, true);
     return $query;
 }
Exemplo n.º 2
0
 /**
  * Find model instances by ids
  * @param int[] $ids
  * @return mixed
  */
 public function findMany($ids)
 {
     $query = new Builder(null);
     $query->setDI($this->di);
     $query->from($this->class);
     return $query->inWhere('id', $ids)->getQuery()->execute();
 }