Show
Ignore:
Timestamp:
10/23/08 19:37:46 (23 months ago)
Author:
mikey
Message:

implement enhancement #180: persistence API should support date instances

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • framework/trunk/src/main/php/net/stubbles/rdbms/persistence/stubPersistenceHelper.php

    r1763 r1896  
    7777            return null; 
    7878        } else { 
    79             $column     = new stubDatabaseTableColumn(); 
     79            $column = new stubDatabaseTableColumn(); 
    8080            $column->setName($this->getPropertyName($method->getName())); 
    8181            $returnType = $method->getReturnType(); 
     
    8686             
    8787            if ($returnType instanceof stubReflectionClass) { 
    88                 // not supported yet 
    89                 throw new stubPersistenceException('Returning classes from entity getter methods is currently not supported. Sorry. :('); 
    90             } 
    91              
    92             switch ($returnType->value()) { 
    93                 case 'int': 
    94                     $column->setType('INT'); 
    95                     $column->setSize(10); 
    96                     break; 
     88                if ($returnType->getName() !== 'stubDate') { 
     89                    // not supported yet 
     90                    throw new stubPersistenceException('Returning classes from entity getter methods is currently not supported, except for net::stubbles::lang::types::stubDate. Sorry. :('); 
     91                } 
    9792                 
    98                 case 'float': 
    99                     $column->setType('FLOAT'); 
    100                     $column->setSize(10); 
    101                     break; 
    102                  
    103                 case 'bool': 
    104                     $column->setType('TINYINT'); 
    105                     $column->setSize(1); 
    106                     break; 
    107                  
    108                 default: 
    109                     $column->setType('VARCHAR'); 
    110                     $column->setSize(255); 
     93                $column->setType('DATETIME'); 
     94            } else { 
     95                switch ($returnType->value()) { 
     96                    case 'int': 
     97                        $column->setType('INT'); 
     98                        $column->setSize(10); 
     99                        break; 
     100                     
     101                    case 'float': 
     102                        $column->setType('FLOAT'); 
     103                        $column->setSize(10); 
     104                        break; 
     105                     
     106                    case 'bool': 
     107                        $column->setType('TINYINT'); 
     108                        $column->setSize(1); 
     109                        break; 
     110                     
     111                    default: 
     112                        $column->setType('VARCHAR'); 
     113                        $column->setSize(255); 
     114                } 
    111115            } 
    112116        }