コード例 #1
0
ファイル: CategoriaMP.php プロジェクト: neeph/NoTengoNiUno
 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);
         }
     }
     $resultSet = $this->getDbTable()->fetchAll($select);
     $entries = array();
     foreach ($resultSet as $row) {
         $entry = new Application_Model_Categoria();
         if ($attr == null) {
             $entry->setIdCategoria($row->ID_CATEGORIA);
             $entry->setIdProyecto($row->ID_PROYECTO);
             $entry->setCategoria($row->CATEGORIA);
             $entry->setColorCategoria($row->COLOR_CATEGORIA);
             $entry->setEstadoCategoria($row->ESTADO_CATEGORIA);
             $entry->setMonto($row->MONTO);
         } 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;
 }