/** * Executes the current select object and returns the result * * @param integer $fetchMode OPTIONAL * @return PDO_Statement|Zend_Db_Statement */ public function query($fetchMode = null) { $stmt = $this->_adapter->query($this); if ($fetchMode == null) { $fetchMode = $this->_adapter->getFetchMode(); } $stmt->setFetchMode($fetchMode); return $stmt; }
/** * Executes the current select object and returns the result * * @param integer $fetchMode OPTIONAL * @param mixed $bind An array of data to bind to the placeholders. * @return PDO_Statement|Zend_Db_Statement */ public function query($fetchMode = null, $bind = array()) { if (!empty($bind)) { $this->bind($bind); } $stmt = $this->_adapter->query($this); if ($fetchMode == null) { $fetchMode = $this->_adapter->getFetchMode(); } $stmt->setFetchMode($fetchMode); return $stmt; }
/** * _authenticateQuerySelect() - This method accepts a Zend_Db_Select object and * performs a query against the database with that object. * * @param Zend_Db_Select $dbSelect * @throws \Zend\Authentication\Adapter\Exception - when an invalid select * object is encountered * @return array */ protected function _authenticateQuerySelect(\Zend_Db_Select $dbSelect) { try { if ($this->_zendDb->getFetchMode() != \Zend_DB::FETCH_ASSOC) { $origDbFetchMode = $this->_zendDb->getFetchMode(); $this->_zendDb->setFetchMode(\Zend_DB::FETCH_ASSOC); } $resultIdentities = $this->_zendDb->fetchAll($dbSelect->__toString()); if (isset($origDbFetchMode)) { $this->_zendDb->setFetchMode($origDbFetchMode); unset($origDbFetchMode); } } catch (\Exception $e) { throw new Exception('The supplied parameters to Zend\\Authentication\\Adapter\\DbTable failed to ' . 'produce a valid sql statement, please check table and column names ' . 'for validity.', 0, $e); } return $resultIdentities; }
/** * _authenticateQuerySelect() - This method accepts a Zend_Db_Select object and * performs a query against the database with that object. * * @param Zend_Db_Select $dbSelect * @throws Zend_Auth_Adapter_Exception - when an invalid select * object is encountered * @return array */ protected function _authenticateQuerySelect(Zend_Db_Select $dbSelect) { try { if ($this->_zendDb->getFetchMode() != Zend_DB::FETCH_ASSOC) { $origDbFetchMode = $this->_zendDb->getFetchMode(); $this->_zendDb->setFetchMode(Zend_DB::FETCH_ASSOC); } $resultIdentities = $this->_zendDb->fetchAll($dbSelect->__toString()); if (isset($origDbFetchMode)) { $this->_zendDb->setFetchMode($origDbFetchMode); unset($origDbFetchMode); } } catch (Exception $e) { /** * @see Zend_Auth_Adapter_Exception */ require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('The supplied parameters to Zend_Auth_Adapter_DbTable failed to ' . 'produce a valid sql statement, please check table and column names ' . 'for validity.', 0, $e); } return $resultIdentities; }
/** * _authenticateQuerySelect() - This method accepts a Zend_Db_Select object and * performs a query against the database with that object. * * @param Zend_Db_Select $dbSelect * @throws Zend_Auth_Adapter_Exception - when an invalid select * object is encountered * @return array */ protected function _authenticateQuerySelect(Zend_Db_Select $dbSelect) { try { if ($this->_zendDb->getFetchMode() != Zend_DB::FETCH_ASSOC) { $origDbFetchMode = $this->_zendDb->getFetchMode(); $this->_zendDb->setFetchMode(Zend_DB::FETCH_ASSOC); } $resultIdentities = $this->_zendDb->fetchAll($dbSelect); if (isset($origDbFetchMode)) { $this->_zendDb->setFetchMode($origDbFetchMode); unset($origDbFetchMode); } } catch (Exception $e) { /** * @see Zend_Auth_Adapter_Exception */ require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('O sistema falhou ao tentar executar o script de autenticação. ' . 'Por favor, entre em contato com o suporte ' . 'e informe o ocorrido..', 0, $e); } return $resultIdentities; }
/** * Support method for fetching rows. * * @param string $type Whether to fetch 'all' or 'row'. * @param string|array $where OPTIONAL An SQL WHERE clause. * @param string|array $order OPTIONAL An SQL ORDER clause. * @param int $count OPTIONAL An SQL LIMIT count. * @param int $offset OPTIONAL An SQL LIMIT offset. * @return mixed The row results per the Zend_Db_Adapter fetch mode. */ protected function _fetch($type, $where = null, $order = null, $count = null, $offset = null) { // selection tool $select = $this->_db->select(); // the FROM clause $select->from($this->_name, $this->_cols); // the WHERE clause $where = (array) $where; foreach ($where as $key => $val) { // is $key an int? if (is_int($key)) { // $val is the full condition $select->where($val); } else { // $key is the condition with placeholder, // and $val is quoted into the condition $select->where($key, $val); } } // the ORDER clause if (!is_array($order)) { $order = array($order); } foreach ($order as $val) { $select->order($val); } // the LIMIT clause $select->limit($count, $offset); // return the results $method = "fetch{$type}"; $mode = $this->_db->getFetchMode(); $this->_db->setFetchMode(Zend_Db::FETCH_ASSOC); $data = $this->_db->{$method}($select); $this->_db->setFetchMode($mode); return $data; }
/** * Get the fetch mode. * * @return int */ public function getFetchMode() { return $this->_adapter->getFetchMode(); }