Esempio n. 1
0
 /**
  * Connect to db server.
  *
  * @throws Phoenix\Exceptions\FailureException
  * @return void
  */
 private function connect()
 {
     $cp = Config::getDatabasePool($this->pool_id);
     try {
         if (empty($cp) || !is_array($cp)) {
             throw new PDOException();
         }
         $this->link = new PDO(sprintf("%s:host=%s:%d;dbname=%s;charset=%s", $cp[Config::DB_DRIVER], $cp[Config::DB_SERVER], $cp[Config::DB_PORT], $cp[Config::DB_SCHEMA], $cp[Config::DB_CHARSET]), $cp[Config::DB_LOGIN], $cp[Config::DB_PASSWORD]);
         $this->link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $this->status = true;
     } catch (PDOException $e) {
         $this->status = false;
         throw new FailureException(FX::F_DB_UNABLE_CONNECT);
     }
 }
Esempio n. 2
0
 public function testDisableRegistration()
 {
     Config::disableRegistration();
     /* modify user defined config */
     Config::set(2001, "XDD");
     $this->assertSame("string", Config::get(2001));
     Config::set(Config::KEY_FORCE_HTTPS, false);
     $this->assertTrue(Config::get(Config::KEY_FORCE_HTTPS));
     /* modify DIR_ROOT */
     Config::set(Config::KEY_DIR_ROOT, "/srv/www/88");
     $this->assertEquals("/srv/www", Config::get(Config::KEY_DIR_ROOT));
     /* modify Database pool 1 */
     Config::setDatabasePool(1, "mysql", "localhost", "3306", "MODIFIED", "", "db", "utf8");
     $expected1 = array(1 => "mysql", 2 => "localhost", 3 => "3306", 4 => "login", 5 => "", 6 => "db", 7 => "utf8");
     $actual1 = Config::getDatabasePool(1);
     $this->assertSame(array_diff($expected1, $actual1), array_diff($actual1, $expected1));
     /* add Database pool 4 */
     Config::setDatabasePool(4, "mysql", "localhost", "3306", "login4", "444", "db", "utf8");
     $this->assertNull(Config::getDatabasePool(4));
     /* modify Email pool 1 */
     Config::setEmailPool(1, "localhost", "25", "MODIFIED", "pass", true, "tls", "Test1");
     $expected2 = array(1 => "localhost", 2 => "25", 3 => "login", 4 => "pass", 5 => true, 6 => "tls", 7 => "Test1");
     $actual2 = Config::getEmailPool(1);
     $this->assertSame(array_diff($expected2, $actual2), array_diff($actual2, $expected2));
     /* add Email pool 4 */
     Config::setEmailPool(4, "localhost", "25", "login", "passWORD", true, "ssl", "Test3");
     $this->assertNull(Config::getDatabasePool(4));
 }