Пример #1
0
 /**
  * 结束事务
  */
 public static function end()
 {
     self::rollback();
     self::$autocommit = true;
     foreach (self::$instance as $db) {
         $db->handler->autocommit(true);
     }
 }
Пример #2
0
 /**
  * 构造函数
  * @param string $code
  * @param array $params
  * @param string $html
  */
 public function __construct($code, $params = array(), $html = "500")
 {
     $message = $this->fmt_code($code, $params);
     //        \Biny\Logger::error($message, array('file'=>$this->getFile().":".$this->getLine(), 'trace'=>$this->getTraceAsString()));
     if (class_exists('TXEvent')) {
         TXEvent::trigger(onException, array($code, array($message, $this->getTraceAsString())));
     }
     if (class_exists('TXDatabase')) {
         TXDatabase::rollback();
     }
     try {
         if (RUN_SHELL) {
             echo "<b>Fatal error</b>:  {$message} in <b>{$this->getFile()}</b>:<b>{$this->getLine()}</b>\nStack trace:\n{$this->getTraceAsString()}";
             exit;
         }
         if ($httpCode = TXConfig::getConfig($html, 'http')) {
             header($httpCode);
         }
         if (SYS_DEBUG) {
             echo "<pre>";
             echo "<b>Fatal error</b>:  {$message} in <b>{$this->getFile()}</b>:<b>{$this->getLine()}</b>\nStack trace:\n{$this->getTraceAsString()}";
         } else {
             if (TXApp::$base->request->isShowTpl() || !TXApp::$base->request->isAjax()) {
                 $params = ['CDN_ROOT' => TXConfig::getAppConfig('CDN_ROOT')];
                 echo new TXResponse("error/exception", array('msg' => $this->messages[$html] ?: "系统数据异常:{$html}"), $params);
             } else {
                 $data = array("flag" => false, "error" => $this->messages[$html] ?: "系统数据异常:{$html}");
                 echo new TXJSONResponse($data);
             }
         }
         die;
     } catch (TXException $ex) {
         //防止异常的死循环
         echo "system Error";
         exit;
     }
 }
Пример #3
0
 /**
  * 从库查询SQL
  * @param $sql
  * @param $key
  * @param int $mode
  * @return array
  */
 private function sql($sql, $key = null, $mode = self::FETCH_TYPE_ALL)
 {
     $dns = is_array($this->dbConfig) ? $this->dbConfig[1] : $this->dbConfig;
     return TXDatabase::instance($dns)->sql($sql, $key, $mode);
 }