Driver options: - database => the name of the local Oracle instance or the name of the entry in tnsnames.ora - username (or user) - password (or pass) - charset => character encoding to set - schema => alters session schema - formatDate => how to format date in SQL (@see date) - formatDateTime => how to format datetime in SQL (@see date) - resource (resource) => existing connection resource - persistent => Creates persistent connections with oci_pconnect instead of oci_new_connect - lazy, profiler, result, substitutes, ... => see Dibi\Connection options
Inheritance: implements Dibi\Driver, implements Dibi\ResultDriver, implements Dibi\Reflector, use trait Dibi\Strict
Beispiel #1
0
 /**
  * Executes the SQL query.
  * @param  string      SQL statement.
  * @return Dibi\ResultDriver|NULL
  * @throws Dibi\DriverException
  */
 public function query($sql)
 {
     // must detect if SQL returns result set or num of affected rows
     $cmd = strtoupper(substr(ltrim($sql), 0, 6));
     static $list = ['UPDATE' => 1, 'DELETE' => 1, 'INSERT' => 1, 'REPLAC' => 1];
     $this->affectedRows = FALSE;
     if (isset($list[$cmd])) {
         $this->affectedRows = $this->connection->exec($sql);
         if ($this->affectedRows !== FALSE) {
             return;
         }
     } else {
         $res = $this->connection->query($sql);
         if ($res) {
             return $this->createResultDriver($res);
         }
     }
     list($sqlState, $code, $message) = $this->connection->errorInfo();
     $message = "SQLSTATE[{$sqlState}]: {$message}";
     switch ($this->driverName) {
         case 'mysql':
             throw MySqliDriver::createException($message, $code, $sql);
         case 'oci':
             throw OracleDriver::createException($message, $code, $sql);
         case 'pgsql':
             throw PostgreDriver::createException($message, $sqlState, $sql);
         case 'sqlite':
             throw Sqlite3Driver::createException($message, $code, $sql);
         default:
             throw new Dibi\DriverException($message, $code, $sql);
     }
 }