Пример #1
0
 /**
  * lists
  * List all available Db implementations in the system
  *
  * @return Array Return an array of string of the available Db implementation
  */
 public static function lists()
 {
     if (is_null(self::$_cacheLists)) {
         $dircontents = scandir(IEM_PATH . '/ext/database/');
         $lists = array();
         foreach ($dircontents as $each) {
             if (in_array($each, array('.', '..' . 'db.php'))) {
                 continue;
             }
             list($filename, $ext) = explode('.', $each);
             array_push($lists, $filename);
         }
         self::$_cacheLists = $lists;
     }
     return self::$_cacheLists;
 }
Пример #2
0
 /**
  * Get database
  * Get the database object that is used by the framework
  *
  * @param Db $overwriteDB Database object to use (OPTIONAL)
  * @return Db|FALSE Returns a concrete implementation of the database object if successful, FALSE otherwise
  *
  * @uses Db
  * @uses SENDSTUDIO_DATABASE_TYPE
  * @uses SENDSTUDIO_DATABASE_HOST
  * @uses SENDSTUDIO_DATABASE_USER
  * @uses SENDSTUDIO_DATABASE_PASSWORD
  * @uses SENDSTUDIO_DATABASE_NAME
  */
 public static final function getDatabase($overwriteDB = null)
 {
     static $db = null;
     static $characterset_defined = false;
     if (!is_null($overwriteDB) && $overwriteDB instanceof Db) {
         $db = $overwriteDB;
     }
     if (is_null($db)) {
         while (true) {
             $required_constants = array('SENDSTUDIO_DATABASE_TYPE', 'SENDSTUDIO_DATABASE_HOST', 'SENDSTUDIO_DATABASE_USER', 'SENDSTUDIO_DATABASE_PASS', 'SENDSTUDIO_DATABASE_NAME');
             $all_ok = false;
             foreach ($required_constants as $required) {
                 if (!defined($required)) {
                     break;
                 }
                 $all_ok = true;
             }
             if (!$all_ok) {
                 break;
             }
             try {
                 $db = IEM_DBFACTORY::manufacture(SENDSTUDIO_DATABASE_TYPE, SENDSTUDIO_DATABASE_HOST, SENDSTUDIO_DATABASE_USER, SENDSTUDIO_DATABASE_PASS, SENDSTUDIO_DATABASE_NAME);
                 $db->TablePrefix = SENDSTUDIO_TABLEPREFIX;
             } catch (exception $e) {
                 $db = false;
                 break;
             }
             break;
         }
         if (is_null($db)) {
             $db = false;
         }
     }
     while (!$characterset_defined) {
         if (is_null($db) || $db === false || !defined('SENDSTUDIO_DATABASE_TYPE')) {
             break;
         }
         if (SENDSTUDIO_DATABASE_TYPE != 'mysql') {
             $characterset_defined = true;
             break;
         }
         if (!defined('SENDSTUDIO_CHARSET')) {
             break;
         }
         if (SENDSTUDIO_CHARSET != 'UTF-8') {
             $characterset_defined = true;
             break;
         }
         if (!defined('SENDSTUDIO_DATABASE_UTF8PATCH')) {
             define('SENDSTUDIO_DATABASE_UTF8PATCH', false);
         }
         if (!SENDSTUDIO_DATABASE_UTF8PATCH) {
             $characterset_defined = true;
             break;
         }
         $db->Query("SET NAMES 'utf8'");
         $db->charset = 'utf8';
         $characterset_defined = true;
         break;
     }
     return $db;
 }
Пример #3
0
 public static final function getDatabase()
 {
     static $db = null;
     static $characterset_defined = false;
     if (self::configGet() !== false) {
         try {
             $db = IEM_DBFACTORY::manufacture(SENDSTUDIO_DATABASE_TYPE, SENDSTUDIO_DATABASE_HOST, SENDSTUDIO_DATABASE_USER, SENDSTUDIO_DATABASE_PASS, SENDSTUDIO_DATABASE_NAME);
             $db->TablePrefix = SENDSTUDIO_TABLEPREFIX;
         } catch (Exception $e) {
             trigger_error($e->getMessage());
             $db = false;
         }
     } else {
         $db = false;
     }
     if (is_null($db)) {
         $db = false;
     }
     return $db;
 }