Exemplo n.º 1
0
 /**
  * @param Driver\DriverInterface $driver
  * @return Platform\PlatformInterface
  */
 protected function createPlatform($parameters)
 {
     if (isset($parameters['platform'])) {
         $platformName = $parameters['platform'];
     } elseif ($this->driver instanceof Driver\DriverInterface) {
         $platformName = $this->driver->getDatabasePlatformName(Driver\DriverInterface::NAME_FORMAT_CAMELCASE);
     } else {
         throw new Exception\InvalidArgumentException('A platform could not be determined from the provided configuration');
     }
     $options = isset($parameters['platform_options']) ? $parameters['platform_options'] : array();
     switch ($platformName) {
         case 'Mysql':
             return new Platform\Mysql($options);
         case 'SqlServer':
             return new Platform\SqlServer($options);
         case 'Oracle':
             return new Platform\Oracle($options);
         case 'Sqlite':
             return new Platform\Sqlite($options);
         case 'Postgresql':
             return new Platform\Postgresql($options);
         case 'IbmDb2':
             return new Platform\IbmDb2($options);
         default:
             return new Platform\Sql92($options);
     }
 }
Exemplo n.º 2
0
 /**
  * @param Driver\DriverInterface $driver
  * @return Platform\PlatformInterface
  */
 protected function createPlatform($parameters)
 {
     if (isset($parameters['platform'])) {
         $platformName = $parameters['platform'];
     } elseif ($this->driver instanceof Driver\DriverInterface) {
         $platformName = $this->driver->getDatabasePlatformName(Driver\DriverInterface::NAME_FORMAT_CAMELCASE);
     } else {
         throw new Exception\InvalidArgumentException('A platform could not be determined from the provided configuration');
     }
     // currently only supported by the IbmDb2 & Oracle concrete implementations
     $options = isset($parameters['platform_options']) ? $parameters['platform_options'] : array();
     switch ($platformName) {
         case 'Mysql':
             // mysqli or pdo_mysql driver
             $driver = $this->driver instanceof Driver\Mysqli\Mysqli || $this->driver instanceof Driver\Pdo\Pdo ? $this->driver : null;
             return new Platform\Mysql($driver);
         case 'SqlServer':
             // PDO is only supported driver for quoting values in this platform
             return new Platform\SqlServer($this->driver instanceof Driver\Pdo\Pdo ? $this->driver : null);
         case 'Oracle':
             // oracle does not accept a driver as an option, no driver specific quoting available
             return new Platform\Oracle($options);
         case 'Sqlite':
             // PDO is only supported driver for quoting values in this platform
             return new Platform\Sqlite($this->driver instanceof Driver\Pdo\Pdo ? $this->driver : null);
         case 'Postgresql':
             // pgsql or pdo postgres driver
             $driver = $this->driver instanceof Driver\Pgsql\Pgsql || $this->driver instanceof Driver\Pdo\Pdo ? $this->driver : null;
             return new Platform\Postgresql($driver);
         case 'IbmDb2':
             // ibm_db2 driver escaping does not need an action connection
             return new Platform\IbmDb2($options);
         default:
             return new Platform\Sql92();
     }
 }
Exemplo n.º 3
0
 /**
  * @param Driver\DriverInterface $driver
  * @return Platform\PlatformInterface
  */
 protected function createPlatformFromDriver(Driver\DriverInterface $driver)
 {
     // consult driver for platform implementation
     $platformName = $driver->getDatabasePlatformName(Driver\DriverInterface::NAME_FORMAT_CAMELCASE);
     switch ($platformName) {
         case 'Mysql':
             return new Platform\Mysql();
         case 'SqlServer':
             return new Platform\SqlServer();
         case 'Sqlite':
             return new Platform\Sqlite();
         default:
             return new Platform\Sql92();
     }
 }