public function fetchAll($attr = null, $where = null) { $select = $this->getDbTable()->select(); if ($attr != null) { $select->from($this->getDbTable(), $attr); } else { $select->from($this->getDbTable()); } if ($where != null) { foreach ($where as $key => $val) { $select->where($key . ' = ?', $val); } } $select->where("ESTADO_REGISTRO = ?", 0); $select->order("FECHA_REGISTRO DESC"); // echo $select; // $select->limit(10,0); $resultSet = $this->getDbTable()->fetchAll($select); $entries = array(); foreach ($resultSet as $row) { $entry = new Application_Model_Registro(); if ($attr == null) { $entry->setIdRegistro($row->ID_REGISTRO); $entry->setIdTipoRegistro($row->ID_TIPO_REGISTRO); $entry->setIdCategoria($row->ID_CATEGORIA); $entry->setIdProyecto($row->ID_PROYECTO); $entry->setIdUsuario($row->ID_USUARIO); $entry->setMontoRegistro($row->MONTO_REGISTRO); $entry->setFechaRegistro($row->FECHA_REGISTRO); $entry->setDescRegistro($row->DESC_REGISTRO); } else { foreach($attr as $a) { $ta = strtolower($a); $ta = split("_", $ta); $method = "set"; foreach($ta as $pa) { $method .= ucfirst($pa); } $entry->$method($row->$a); } } $entries[] = $entry; } return $entries; }