Exemplo n.º 1
0
 /**
  * @param array      $settings        A configuration array with the following keys:<p>
  *                                    <table cellspacing=0 cellpadding=0>
  *                                    <tr><kbd>database        <td>The database name.
  *                                    <tr><kbd>host            <td>The database server's host IP or domain name.
  *                                    <tr><kbd>port            <td>The database server's port (optional).
  *                                    <tr><kbd>username &nbsp; <td>The username.
  *                                    <tr><kbd>password        <td>The password.
  *                                    </table>
  * @param array|null $optionsOverride Entries on this array override the default PDO connection options.
  */
 function __construct(array $settings, array $optionsOverride = null)
 {
     if (isset($optionsOverride)) {
         foreach ($optionsOverride as $k => $v) {
             $this->options[$k] = $v;
         }
     }
     $dsn = "pgsql:dbname={$settings['database']};host={$settings['host']}";
     if (isset($settings['port'])) {
         $dsn .= ";port={$settings['port']}";
     }
     parent::__construct($dsn, $settings['username'], $settings['password'], $this->options);
 }
Exemplo n.º 2
0
 /**
  * @param array      $settings        A configuration array with the following keys:<p>
  *                                    <table cellspacing=0 cellpadding=0>
  *                                    <tr><kbd>database &nbsp; <td>The database filename. Use ':memory:' for an
  *                                    in-memory db.
  *                                    </table>
  * @param array|null $optionsOverride Entries on this array override the default PDO connection options.
  */
 function __construct(array $settings, array $optionsOverride = null)
 {
     $database = $settings['database'];
     if ($database != ':memory:') {
         if (!file_exists($database)) {
             touch($database);
         }
     }
     if (isset($optionsOverride)) {
         foreach ($optionsOverride as $k => $v) {
             $this->options[$k] = $v;
         }
     }
     parent::__construct("sqlite:{$database}", '', '', $this->options);
     if ($this->enableForeignKeys) {
         $this->exec('PRAGMA foreign_keys = ON;');
     }
 }
Exemplo n.º 3
0
 /**
  * @param array      $settings        A configuration array with the following keys:<p>
  *                                    <table cellspacing=0 cellpadding=0>
  *                                    <tr><kbd>database           <td>The database name.
  *                                    <tr><kbd>host               <td>The database server's host IP or domain name.
  *                                    <tr><kbd>port               <td>The database server's port (optional).
  *                                    <tr><kbd>unixSocket &nbsp;  <td>The connection's UNIX socket (optional).
  *                                    <tr><kbd>charset            <td>The database charset (optional), ex: 'utf8'.
  *                                    <tr><kbd>collation          <td>The database collation (optional),
  *                                    ex:'utf8_unicode_ci'.
  *                                    <tr><kbd>username           <td>The username.
  *                                    <tr><kbd>password           <td>The password.
  *                                    </table>
  * @param array|null $optionsOverride Entries on this array override the default PDO connection options.
  */
 function __construct(array $settings, array $optionsOverride = null)
 {
     $dsn = "mysql:host={$settings['host']};dbname={$settings['database']}";
     if (!empty($settings['port'])) {
         $dsn .= ";port={$settings['port']}";
     }
     if (!empty($settings['unixSocket'])) {
         $dsn .= ";unix_socket={$settings['unixSocket']}";
     }
     if (!empty($settings['charset'])) {
         $cmd = "SET NAMES '{$settings['charset']}'";
         if (!empty($settings['collation'])) {
             $cmd .= " COLLATE '{$settings['collation']}'";
         }
         $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = $cmd;
     }
     if (isset($optionsOverride)) {
         foreach ($optionsOverride as $k => $v) {
             $this->options[$k] = $v;
         }
     }
     parent::__construct($dsn, $settings['username'], $settings['password'], $this->options);
 }
 /**
  * Override to provide an implementation of a database transaction rollback.
  */
 protected function rollback()
 {
     $this->pdo->rollBack();
 }
Exemplo n.º 5
0
 function getPdo(array $options = null)
 {
     return $this->pdo ?: ($this->pdo = ExtPDO::create($this->driver, $this->getProperties(), $options));
 }