Example #1
0
 /**
  * setDb
  *
  * @param   AbstractDatabaseDriver $db
  *
  * @return  void
  */
 public static function setDefaultDbo(AbstractDatabaseDriver $db = null)
 {
     self::$db = $db;
     if ($db) {
         $driver = $db->getName();
         self::$instances[$driver] = $db;
     }
 }
Example #2
0
 /**
  * batchQuery
  *
  * @param   AbstractDatabaseDriver $db
  * @param   array|string   $queries
  *
  * @return  boolean
  */
 public static function batchQuery(AbstractDatabaseDriver $db, $queries)
 {
     if (is_string($queries)) {
         $queries = $db->splitSql($queries);
     }
     foreach ((array) $queries as $query) {
         if (!trim($query)) {
             continue;
         }
         $db->setQuery($query)->execute();
     }
     return true;
 }
 /**
  * Destruct.
  */
 public function __destruct()
 {
     if (!self::$dbo) {
         return;
     }
     static::$debug or self::$dbo->setQuery('DROP DATABASE IF EXISTS ' . self::$dbo->quoteName(static::$dbname))->execute();
     self::$dbo = null;
 }
Example #4
0
 /**
  * gc
  *
  * @param string $past
  *
  * @return  bool
  */
 public function gc($past)
 {
     $query = $this->db->getQuery(true);
     $query->delete($this->db->quoteName($this->options['table']))->where($this->db->quoteName($this->options['time_col']) . ' < ' . $this->db->quote((int) $past));
     // Remove expired sessions from the database.
     $this->db->setQuery($query);
     return (bool) $this->db->execute();
 }
Example #5
0
 /**
  * getFilterFields
  *
  * @return  array
  */
 public function getSelectFields()
 {
     $fields = array();
     $i = 0;
     foreach ($this->tables as $alias => $table) {
         $columns = $this->db->getTable($table['name'])->getColumns();
         foreach ($columns as $column) {
             $prefix = $table['prefix'];
             if ($i === 0) {
                 $prefix = $prefix === null ? false : true;
             } else {
                 $prefix = $prefix === null ? true : false;
             }
             if ($prefix === true) {
                 $fields[] = $this->db->quoteName("{$alias}.{$column} AS {$alias}_{$column}");
             } else {
                 $fields[] = $this->db->quoteName("{$alias}.{$column} AS {$column}");
             }
         }
         $i++;
     }
     return $fields;
 }
Example #6
0
 /**
  * Quick quote name.
  *
  * @param string $value
  *
  * @return  mixed
  */
 public function qn($value)
 {
     return $this->db->quoteName($value);
 }
 /**
  * transactionRollback
  *
  * @param bool $asSavePoint
  *
  * @return  $this
  */
 public function transactionRollback($asSavePoint = false)
 {
     $this->db->getTransaction()->rollback($asSavePoint);
     return $this;
 }
Example #8
0
 /**
  * Method to get the auto-incremented value from the last INSERT statement.
  *
  * @return  string  The value of the auto-increment field from the last inserted row.
  *
  * @since   2.0
  */
 public function insertId()
 {
     return $this->db->getReader()->insertId();
 }
Example #9
0
 /**
  * freeResult
  *
  * @return  $this
  */
 public function freeResult()
 {
     $this->db->freeResult();
     return $this;
 }