コード例 #1
0
ファイル: db.php プロジェクト: nsswaga/OSClass
function getConnection($dbHost = null, $dbUser = null, $dbPassword = null, $dbName = null, $dbLogLevel = null)
{
    static $instance;
    //DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, DEBUG_LEVEL
    if (defined('DB_HOST') && $dbHost == null) {
        $dbHost = osc_db_host();
    }
    if (defined('DB_USER') && $dbUser == null) {
        $dbUser = osc_db_user();
    }
    if (defined('DB_PASSWORD') && $dbPassword == null) {
        $dbPassword = osc_db_password();
    }
    if (defined('DB_NAME') && $dbName == null) {
        $dbName = osc_db_name();
    }
    if (defined('DEBUG_LEVEL') && $dbLogLevel == null) {
        $dbLogLevel = DEBUG_LEVEL;
    }
    if (!isset($instance[$dbName . "_" . $dbHost])) {
        if (!isset($instance)) {
            $instance = array();
        }
        $instance[$dbName . "_" . $dbHost] = new DB($dbHost, $dbUser, $dbPassword, $dbName, $dbLogLevel);
    }
    return $instance[$dbName . "_" . $dbHost];
}
コード例 #2
0
ファイル: DAO.php プロジェクト: hashemgamal/OSClass
 public function __construct()
 {
     $this->conn = getConnection(osc_db_host(), osc_db_user(), osc_db_password(), osc_db_name(), DEBUG_LEVEL);
 }
コード例 #3
0
function is_osclass_installed()
{
    if (!file_exists(ABS_PATH . 'config.php')) {
        return false;
    }
    require_once ABS_PATH . 'config.php';
    $conn = new DBConnectionClass(osc_db_host(), osc_db_user(), osc_db_password(), osc_db_name());
    $c_db = $conn->getOsclassDb();
    $comm = new DBCommandClass($c_db);
    $rs = $comm->query(sprintf("SELECT * FROM %st_preference WHERE s_name = 'osclass_installed'", DB_TABLE_PREFIX));
    if ($rs == false) {
        return false;
    }
    if ($rs->numRows() != 1) {
        return false;
    }
    return true;
}
コード例 #4
0
 /**
  * It creates a new DBConnection object class or if it has been created before, it 
  * returns the previous object
  * 
  * @access public
  * @since 2.3
  * @param string $server Host name where it's located the mysql server
  * @param string $user MySQL user name
  * @param string $password MySQL password
  * @param string $database Default database to be used when performing queries
  * @return DBConnectionClass 
  */
 public static function newInstance($server = '', $user = '', $password = '', $database = '')
 {
     $server = $server == '' ? osc_db_host() : $server;
     $user = $user == '' ? osc_db_user() : $user;
     $password = $password == '' ? osc_db_password() : $password;
     $database = $database == '' ? osc_db_name() : $database;
     if (!self::$instance instanceof self) {
         self::$instance = new self($server, $user, $password, $database);
     }
     return self::$instance;
 }