Exemplo n.º 1
0
 /**
  *
  * @param array|Zend_Db_Statement $record
  * @param array $columnMappers 
  */
 public function __construct($record = array(), $columnMappers = array(), $returnType = false)
 {
     parent::__construct($record, $columnMappers, $returnType);
 }
Exemplo n.º 2
0
 public function fetchAll()
 {
     $sql = $this->sqlBase();
     $query = new ZendT_Db_Recordset($this->_table->getAdapter()->query($sql, $this->_binds), $this->_columnsMapper);
     return $query->getRows();
 }
Exemplo n.º 3
0
 /**
  *
  * @return \ZendT_Db_Recordset 
  */
 public function getRecordSet()
 {
     $stmt = $this->_table->getAdapter()->query($this->getSql());
     $obj = new ZendT_Db_Recordset($stmt, $this->_mappers, true);
     if (count($this->_replaceAlias) > 0) {
         foreach ($this->_replaceAlias as $key => $value) {
             $obj->addReplaceAlias($key, $value);
         }
     }
     return $obj;
 }
Exemplo n.º 4
0
 /**
  * Retorna os registros da tabela
  *
  * @param array|ZendT_Db_Where $where
  * @param array|string $columns
  * @param array|string $orderBy 
  */
 public function getRows($where = null, $columns = null, $orderBy = null, $type = false, $lock = false)
 {
     if ($columns == null || $columns == '') {
         $columns = array('*');
     }
     if ($orderBy == null || $orderBy == '') {
         $orderBy = array('1');
     }
     if (is_string($columns)) {
         $columns = array($columns);
     }
     if (is_string($orderBy)) {
         $orderBy = array($orderBy);
     }
     if (is_array($where)) {
         $_where = new ZendT_Db_Where('AND');
         foreach ($where as $column => $value) {
             //$_where->addFilter($column, $value);
             $_where->addFilter($column, $value, '=', $this->_mapper, true);
         }
         $where = $_where;
         $binds = $where->getBinds();
         $cmdwhere = $where->getSqlWhere();
     } elseif ($where instanceof ZendT_Db_Where || $where instanceof ZendT_Db_Where_Group) {
         $binds = $where->getBinds();
         $cmdwhere = $where->getSqlWhere();
     } elseif (is_numeric($where)) {
         $cmdwhere = 'id = :id';
         $binds = array('id' => $where);
     } elseif (is_string($where)) {
         $cmdwhere = $where;
     } elseif (is_int($where)) {
         $cmdwhere = 'id = :id';
         $binds = array('id' => $where);
     } elseif ($where === null) {
         $cmdwhere = '1 = 1';
         $binds = array();
     } else {
         $cmdwhere = '1 = 1';
         $binds = array();
     }
     $sql = 'SELECT ' . implode(',', $columns) . ' FROM ' . $this->getTableName() . ' ' . $this->getAlias() . ' WHERE ' . $cmdwhere;
     $sql .= ' ORDER BY ' . implode(',', $orderBy);
     if ($lock) {
         $sql .= ' FOR UPDATE';
     }
     $stmt = $this->getAdapter()->query($sql, $binds);
     if ($this->_columnMappers == '') {
         $this->_columnMappers = new ZendT_Db_Column_Mapper();
         $this->_columnMappers->add('default', $this->_mapper);
         /* foreach ($columns as $column){
            $this->_columnMappers->add($column, $this->_mapper);
            } */
     }
     if ($type) {
         $recordset = new ZendT_Db_Recordset($stmt, $this->_columnMappers, $type);
     } else {
         $recordset = new ZendT_Db_Recordset($stmt);
     }
     return $recordset->getRows();
 }