Exemple #1
0
 /**
  * Swap between types depending on the driver.
  */
 public function initialize()
 {
     parent::initialize();
     $driver = $this->getDriver();
     if ($driver instanceof \Titon\Db\Pgsql\PgsqlDriver) {
         foreach ($this->_schema as $field => $data) {
             if ($field === 'id') {
                 $this->_schema[$field] = ['type' => 'serial', 'null' => false, 'primary' => true];
             } else {
                 if (is_array($data)) {
                     $this->_schema[$field]['type'] = $this->migratePgsql($data['type']);
                 } else {
                     $this->_schema[$field] = $this->migratePgsql($data);
                 }
             }
         }
     } else {
         if ($driver instanceof \Titon\Db\Mongo\MongoDriver) {
             $this->setConfig('primaryKey', '_id');
             $this->_schema = [];
         }
     }
 }