示例#1
0
 public function __construct(array $connection_options = array())
 {
     $this->transactionSupport = TRUE;
     // Transactional DDL is always available in PostgreSQL,
     $this->transactionalDDLSupport = TRUE;
     $pdo = parent::openConnection(array(PDO::ATTR_EMULATE_PREPARES => FALSE, PDO::ATTR_STRINGIFY_FETCHES => TRUE, PDO::ATTR_CASE => PDO::CASE_LOWER));
     parent::__construct($pdo);
     // Force PostgreSQL to use the UTF-8 character set by default.
     $pdo->exec("SET NAMES 'UTF8'");
 }
示例#2
0
 public function __construct(array $connection_options = array())
 {
     $this->transactionSupport = FALSE;
     // MySQL never supports transactional DDL.
     $this->transactionalDDLSupport = FALSE;
     $pdo = parent::openConnection(array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE, PDO::ATTR_EMULATE_PREPARES => TRUE, PDO::ATTR_CASE => PDO::CASE_LOWER));
     parent::__construct($pdo);
     // Force MySQL to use the UTF-8 character set.
     $pdo->exec('SET NAMES utf8');
     // Force MySQL's behavior to conform more closely to SQL standards.
     // This allows Drupal to run almost seamlessly on many different
     // kinds of database systems. These settings force MySQL to behave
     // the same as postgresql, or sqlite in regards to syntax interpretation
     // and invalid data handling. See http://drupal.org/node/344575 for further discussion.
     $pdo->exec("SET sql_mode='ANSI,TRADITIONAL'");
 }
示例#3
0
 private static function _buildMenu()
 {
     $app = KX_CURRENT_APP;
     if (KX_CURRENT_APP == 'core' && !isset(kxEnv::$request['module']) && !isset(kxEnv::$request['app'])) {
         $modules = array(array('module_file' => 'index'));
     } else {
         $modules = kxDB::getinstance()->select("modules", "", array('fetch' => PDO::FETCH_ASSOC))->fields("modules", array("module_name", "module_file"))->condition("module_application", $app)->condition("module_manage", 1)->orderBy("module_position")->execute()->fetchAll();
     }
     //print_r($modules);
     foreach ($modules as $module) {
         $_file = kxFunc::getAppDir($app) . "/modules/manage/" . $module['module_file'] . '/menu.yml';
         //echo "<p>Getting menu from {$_file}</p>";
         if (file_exists($_file)) {
             if (function_exists("syck_load")) {
                 $menu[$module['module_file']] = syck_load(file_get_contents($_file));
             } else {
                 $menu[$module['module_file']] = spyc_load_file($_file);
             }
             self::assign('menu', $menu);
             self::assign('module', $module['module_file']);
         }
     }
 }
示例#4
0
 public function __construct(kxEnv $environment)
 {
     $this->environment = $environment;
     $this->db = kxDB::getInstance();
     $this->request = kxEnv::$request;
 }
示例#5
0
 /**
  * Rolls back the current transaction.
  *
  * This is just a wrapper method to rollback whatever transaction stack we are
  * currently in, which is managed by the connection object itself. Note that
  * logging (preferable with watchdog_exception()) needs to happen after a
  * transaction has been rolled back or the log messages will be rolled back
  * too.
  *
  * @see kxDB::rollback()
  * @see watchdog_exception()
  */
 public function rollback()
 {
     $this->rolledBack = TRUE;
     $this->connection->rollback($this->name);
 }
示例#6
0
 /**
  * Make shortcuts for kxEnv and kxDB
  *
  * @access	public
  * @param	object	kxEnv reference
  * @return	void
  */
 public function makeRegistryShortcuts(kxEnv $environment)
 {
     $this->environment = $environment;
     $this->db = kxDB::getinstance();
     $this->request = kxEnv::$request;
 }
示例#7
0
 /**
  * Set a cache
  *
  * @param  string  Cache Key
  * @param  mixed  Cache value
  */
 private function _setCache($path, $value)
 {
     if ($path) {
         // First, update the already-loaded cache with the new value
         $return = kxEnv::getconfig()->setRecursive($path, $value);
         // Are we using an alt cache engine?
         // Update it if so
         if (is_object(self::$cacheLib)) {
             if (!$value) {
                 $value = "NULL";
             }
             self::$cacheLib->update(implode(':', $path), $value);
         }
         // Now update the database
         // Merge does an update if the key exists, otherwise, it inserts
         kxDB::getInstance()->merge("cache")->key(array("cache_path" => implode(':', $path)))->fields(array("cache_array" => intval(is_array($value)), "cache_value" => is_array($value) ? serialize($value) : $value, "cache_updated" => time()))->execute();
         return $return;
     }
 }
示例#8
0
 public function popTransaction($name)
 {
     if ($this->savepointSupport) {
         return parent::popTransaction($name);
     }
     if (!$this->supportsTransactions()) {
         return;
     }
     if (!$this->inTransaction()) {
         throw new DatabaseTransactionNoActiveException();
     }
     // Commit everything since SAVEPOINT $name.
     while ($savepoint = array_pop($this->transactionLayers)) {
         if ($savepoint != $name) {
             continue;
         }
         // If there are no more layers left then we should commit or rollback.
         if (empty($this->transactionLayers)) {
             // If there was any rollback() we should roll back whole transaction.
             if ($this->willRollback) {
                 $this->willRollback = FALSE;
                 PDO::rollBack();
             } elseif (!PDO::commit()) {
                 throw new DatabaseTransactionCommitFailedException();
             }
         } else {
             break;
         }
     }
 }
示例#9
0
 public static function BanUser($ip, $modname, $globalban, $duration, $boards, $reason, $staffnote, $appealat = 0, $type = 0, $allowread = 1, $proxyban = false)
 {
     if ($duration > 0) {
         $ban_globalban = '0';
     } else {
         $ban_globalban = '1';
     }
     if ($duration > 0) {
         $ban_until = time() + $duration;
     } else {
         $ban_until = '0';
     }
     kxDB::getinstance()->exec("INSERT INTO `" . kxEnv::Get('kx:db:prefix') . "banlist` ( `ip` , `ipmd5` , `type` , `allowread` , `globalban` , `boards` , `by` , `at` , `until` , `reason`, `staffnote`, `appealat` ) VALUES ( " . $kx_db->qstr(md5_encrypt($ip, kxEnv::Get('kx:misc:randomseed'))) . " , " . $kx_db->qstr(md5($ip)) . " , " . intval($type) . " , " . intval($allowread) . " , " . intval($globalban) . " , " . $kx_db->qstr($boards) . " , " . $kx_db->qstr($modname) . " , " . time() . " , " . intval($ban_until) . " , " . $kx_db->qstr($reason) . " , " . $kx_db->qstr($staffnote) . ", " . intval($appealat) . " ) ");
     if (!$proxyban && $type == 1) {
         $this->UpdateHtaccess();
     }
     return true;
 }
示例#10
0
 /**
  * Grab a PDOStatement object from a given query and its arguments.
  *
  * Some drivers (including SQLite) will need to perform some preparation
  * themselves to get the statement right.
  *
  * @param $query
  *   The query.
  * @param array $args
  *   An array of arguments.
  * @return PDOStatement
  *   A PDOStatement object.
  */
 protected function getStatement($query, &$args = array())
 {
     return $this->dbh->prepare($query);
 }
示例#11
0
文件: select.php 项目: D4rk4/Kusaba-z
 public function extend($extender_name)
 {
     // The extender can be anywhere so this needs to go to the registry, which
     // is surely loaded by now.
     $class = $this->connection->getDriverClass($extender_name, array(), TRUE);
     return new $class($this, $this->connection);
 }