/** * Propriedade tem como finalidade executar * a consulta SQL colocando o recordset sobre a mémoria * desse objeto permitindo assim usar o fetch * para posicionar as linhas e realizar alteração sobre * elas * * @param ZendT_Db_Where $where * @return \ZendT_Db_Mapper */ public function findAll($where = null, $fields = array('id'), $orderBy = array('1')) { if ($where == null) { $where = $this->getWhere(); } /** * Monta a base do SQL */ $cmdSelect = " SELECT " . $this->getColumns(true)->getColumnsSelect(true, $fields); $cmdFrom = " FROM " . $this->_getSqlBase(); /** * Trata a entrada do Where para ser um Grupo de Where */ if ($where instanceof ZendT_Db_Where_Group) { $whereGroup = $where; } else { if ($where instanceof ZendT_Db_Where) { $whereGroup = new ZendT_Db_Where_Group(); $whereGroup->addWhere($where); } else { $whereGroup = new ZendT_Db_Where_Group(); } } /** * Avalia se existe algum Where específico do MapperView * colocando o mesmo dentro do objeto que agrupa os wheres */ $_whereMapperView = $this->_getWhere($postData, $where); if ($_whereMapperView) { $whereGroup->addWhere($_whereMapperView); } /** * Monta o comando Where */ $binds = $whereGroup->getBinds(); $cmdWhere = " WHERE " . $whereGroup->getSqlWhere(); /** * */ if (!is_array($orderBy)) { $orderBy = array($orderBy); } /** * Configura o range de dados que será buscado */ $sql = $cmdSelect . $cmdFrom . $cmdWhere . ' ORDER BY ' . implode(',', $orderBy); $this->_prepareSql($sql, $binds, 'full'); /** * Pega os dados */ //$this->_record = $this->getModel()->getAdapter()->query($sql, $binds); $this->_rows = $this->getModel()->getAdapter()->fetchAll($sql, $binds); $this->_iRows = -1; return $this; }