/** * * */ public static function singleton() { if (!is_null(DB_HOST_TT) && !is_null(DB_USER_TT) && !is_null(DB_PSWD_TT) && !is_null(DB_KIND_TT) && !is_null(DB_NAME_TT)) { if (!self::$con && !self::$db) { // 該当DB接続ファイル読み込み include_once APP_DB_PATH . DB_KIND_TT . '.php'; // DBクラス名取得 $db_kind = ucfirst(DB_KIND_TT); // DBインスタンス生成 $db = new $db_kind(); // 初期化 $config = array(); $config['host'] = DB_HOST_TT; $config['user'] = DB_USER_TT; $config['pswd'] = DB_PSWD_TT; $config['db_name'] = DB_NAME_TT; $config['port'] = DB_PORT_TT; // DB接続処理 $con = $db->connect($config); self::$db = $db; self::$con = $con; } } return array('con' => self::$con, 'db' => self::$db); }
public static function GetInstance($DB_TYPE = DB_TYPE, $DB_HOST = DB_HOST, $DB_NAME = DB_NAME, $DB_USER = DB_USER, $DB_PASS = DB_PASSWORD) { if (!isset(self::$instance)) { self::$instance = new self($DB_TYPE, $DB_HOST, $DB_NAME, $DB_USER, $DB_PASS); } return self::$instance; }
/** * コンストラクタ */ public function __construct() { if (empty($this->con)) { $database = TDatabase::singleton(); $this->con = $database['con']; $this->db = $database['db']; } }
/** * @brief Datenbank auswählen * @param string $name Der Name der Datenbank */ public function select($name) { if (!mysql_select_db($name, $this->resource)) { throw new EDatabase(mysql_error(), mysql_errno()); } parent::select($name); }
<?php require_once './../app/core/loader.php'; $dispatch = new TDispatch(); $dispatch->dispatch(); $dbh = TDatabase::singleton();
function getFavorites($userId) { $sql = "SELECT adid\n FROM #__adsmanager_favorite\n WHERE userid = " . (int) $userId; $result = TDatabase::loadColumn($sql); return $result; }
public function delete() { // exclusão $this->adicionaCampos(); parent::delete(); if ($this->result) { $this->clear(); } // retorno return $this->result; }
} global $database_handle; define('__MP__', FALSE); // include all required libs include_once '../tconstant.php'; include_once '../tconfig.php'; include_once '../libs/TDatabasePDO.php'; include_once '../libs/THash.php'; include_once '../libs/TFunction.php'; include_once '../libs/TRegistry.php'; function _hk() { } // try to connect with posted value that sure before write on config. try { $database_handle = new TDatabase(DB_TYPE, DB_HOST, DB_NAME, DB_USER, DB_PASSWORD); $reg = new TRegistry(); } catch (Exception $exc) { echo $exc->getTraceAsString(); die('<br /> We can connect to Database please check your input'); } // else install system $sqls = glob('./sql/*.sql'); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> Toos system install - Finalize</title> <link type="text/css" rel="stylesheet" href="assets/css/install.css" /> <link type="text/css" rel="stylesheet" href="../tcm/assets/css/element.css" />
include_once '../libs/TDatabasePDO.php'; error_reporting(1); // try to read config sample try { $f_name = 'tconfig.sample.php'; $f_handle = fopen($f_name, 'r'); $f_content = fread($f_handle, filesize($f_name)); fclose($f_handle); unset($f_handle); } catch (Exception $exc) { echo $exc->getTraceAsString(); die; } // try to connect with posted value that sure before write on config. try { $dbcon = new TDatabase('mysql', $_POST['dbhost'], $_POST['dbname'], $_POST['dbuser'], $_POST['dbpass']); // check db is empty or not $tbl_result = $dbcon->query("SHOW TABLES"); $tables = $tbl_result->fetchAll(); $is_ext = FALSE; foreach ($tables as $table_name) { if ($table_name[0] == $_POST['dbprf'] . 'registry') { $is_ext = TRUE; break; } } // same as new table fonud install failed if ($is_ext) { die("Toos is installed before than <br /> Please check db or choose " . "another prefix for install other system inside installed " . "system(s)"); } } catch (Exception $exc) {
public function insert() { static $result; $this->adicionaCampos(); $result = parent::insert(); if ($result) { $this->clear(); } return $result; }