コード例 #1
0
ファイル: Recordset.php プロジェクト: rtsantos/mais
 /**
  * Formata os dados do array antes de retornar
  *
  * @param array|stdClass $row 
  */
 private function _formatRow(&$row)
 {
     foreach ($row as $key => $value) {
         $key = strtolower($key);
         $mapperName = '';
         if (isset($this->_columnMappers[$key]) && $this->_columnMappers[$key]['mapper']) {
             $mapperName = $this->_columnMappers[$key]['mapper'];
             $columnName = $this->_columnMappers[$key]['column'];
         } else {
             $mapperName = $this->_columnMappers['default']['mapper'];
             $columnName = $key;
         }
         if (!$mapperName) {
             try {
                 throw new ZendT_Exception('Chave com mapper errado ' . $key);
             } catch (ZendT_Exception $ex) {
                 echo nl2br($ex->getTraceAsString());
             }
         }
         $_type = $this->_getZendTType($mapperName, $columnName, $value);
         if ($_type instanceof ZendT_Type) {
             $_type->setValueFromDb($value);
         } else {
             $app = getenv('APPLICATION_ENV');
             if ($app == 'production' || $app == '' || 1 == 1) {
                 $_type = new ZendT_Type_Number($value);
             } else {
                 throw new ZendT_Exception('Não definido o mapeamento para a coluna "' . $key . '" ');
             }
         }
         /**
          * 
          */
         if ($this->_type) {
             $row[$key] = clone $_type;
         } else {
             $row[$key] = $_type->get();
         }
     }
 }