Ejemplo n.º 1
0
 /**
  * @return void
  */
 public static function closeAll()
 {
     foreach (Sabel_Db_Config::get() as $connectionName => $config) {
         self::close($connectionName);
     }
     self::$connections = array();
 }
Ejemplo n.º 2
0
 public function testConnectionRefused()
 {
     $params = array("package" => "sabel.db.mysql", "host" => "127.0.0.1", "user" => "hogehoge", "password" => "fugafuga", "database" => "sdb_test");
     Sabel_Db_Config::add("conrefused", $params);
     $driver = new Sabel_Db_Mysql_Driver("conrefused");
     try {
         $c = error_reporting(0);
         $resource = Sabel_Db_Connection::connect($driver);
         error_reporting($c);
     } catch (Sabel_Db_Exception_Connection $e) {
         return;
     }
     $this->fail();
 }
Ejemplo n.º 3
0
 /**
  * @param string $connectionName
  *
  * @throws Sabel_Exception_ClassNotFound
  * @return Sabel_Db_Driver
  */
 public static function createDriver($connectionName = "default")
 {
     $className = self::classPrefix($connectionName) . "Driver";
     if (Sabel::using($className)) {
         $driver = new $className($connectionName);
     } elseif ($baseClass = self::getBaseClassName($connectionName, "Driver")) {
         $driver = new $baseClass($connectionName);
     } else {
         $message = __METHOD__ . "() Class '{$className}' not Found.";
         throw new Sabel_Exception_ClassNotFound($message);
     }
     Sabel_Db_Connection::connect($driver);
     return $driver;
 }
Ejemplo n.º 4
0
 public function testClose()
 {
     Sabel_Db_Metadata::clear();
     Sabel_Db_Connection::closeAll();
 }
Ejemplo n.º 5
0
equals($name->default, "default name");
isTrue($name->nullable);
equals($name->max, 128);
isTrue($test->isString());
isFalse($test->primary);
isFalse($test->increment);
isNull($test->default);
isTrue($test->nullable);
equals($test->max, 255);
isTrue($body->isText());
isFalse($body->primary);
isFalse($body->increment);
isNull($body->default);
isFalse($body->nullable);
isTrue($bool->isBool());
isFalse($bool->primary);
isFalse($bool->increment);
isFalse($bool->default);
isTrue($bool->nullable);
isNull($hoge->ft);
isNull($hoge->dbl);
isNull($hoge->sint);
isNull($hoge->bint);
Sabel_Db_Connection::closeAll();
$path = RUN_BASE . "/migration/tmp/1_Hoge_create.php";
system("php exec.php {$path} " . CONNAME . " downgrade");
$accessor = Sabel_Db::createMetadata(CONNAME);
$tables = $accessor->getTableList();
isFalse(in_array("hoge", $tables));
Sabel_Db_Connection::closeAll();
echo "\n";