/** * Returns the query built * * @return \Phalcon\Mvc\Model\Query */ public function getQuery() { //Process the PHQL $phql = $this->getPhql(); $query = new Query($phql, $this->_dependencyInjector); //Set default bind params $bindParams = $this->_bindParams; if (is_array($bindParams) === true) { $query->setBindParams($bindParams); } //Set default bind types $bindTypes = $this->_bindTypes; if (is_array($bindTypes) === true) { $query->setBindTypes($bindTypes); } return $query; }
public function getQuery() { if (!$this->_Phql) { throw new \Exception('please format sql after call this method'); } $where = $this->getWhere(); if (!empty($where)) { $this->_Phql .= ' WHERE ' . $where; } $limit = $this->getLimit(); if (!empty($limit)) { $this->_Phql .= ' LIMIT ' . $limit; } // or new ModelQuery($this->_Phql) call all $query = new \Phalcon\Mvc\Model\Query($this->_Phql, \Phalcon\Di::getDefault()); if (!empty($this->_bindParams)) { $query->setBindParams($this->_bindParams); } if (!empty($this->_bindTypes)) { $query->setBindTypes($this->_bindTypes); } $query->setType($this->_type); $query->setDI(\Phalcon\Di::getDefault()); return $query; }