예제 #1
0
 /**
  * Open a connection and Initiates a transaction
  * @param $database Name of the database (an INI file).
  * @param $dbinfo Optional array with database information
  */
 public static function open($database, $dbinfo = NULL)
 {
     if (!isset(self::$counter)) {
         self::$counter = 0;
     } else {
         self::$counter++;
     }
     if ($dbinfo) {
         self::$conn[self::$counter] = TConnection::openArray($dbinfo);
         self::$dbinfo[self::$counter] = $dbinfo;
     } else {
         self::$conn[self::$counter] = TConnection::open($database);
         self::$dbinfo[self::$counter] = TConnection::getDatabaseInfo($database);
     }
     self::$database[self::$counter] = $database;
     $driver = self::$conn[self::$counter]->getAttribute(PDO::ATTR_DRIVER_NAME);
     if ($driver !== 'dblib') {
         // begins transaction
         self::$conn[self::$counter]->beginTransaction();
     }
     if (!empty(self::$dbinfo[self::$counter]['slog'])) {
         $logClass = self::$dbinfo[self::$counter]['slog'];
         if (class_exists($logClass)) {
             self::setLogger(new $logClass());
         }
     } else {
         // turn OFF the log
         self::$logger[self::$counter] = NULL;
     }
 }
예제 #2
0
 /**
  * Open a connection and Initiates a transaction
  * @param $database Name of the database (an INI file).
  * @param $dbinfo Optional array with database information
  */
 public static function open($database, $dbinfo = NULL)
 {
     if (!isset(self::$counter)) {
         self::$counter = 0;
     } else {
         self::$counter++;
     }
     if ($dbinfo) {
         self::$conn[self::$counter] = TConnection::openArray($dbinfo);
         self::$dbinfo[self::$counter] = $dbinfo;
     } else {
         self::$conn[self::$counter] = TConnection::open($database);
         self::$dbinfo[self::$counter] = TConnection::getDatabaseInfo($database);
     }
     self::$database[self::$counter] = $database;
     $driver = self::$conn[self::$counter]->getAttribute(PDO::ATTR_DRIVER_NAME);
     if ($driver !== 'dblib') {
         // begins transaction
         self::$conn[self::$counter]->beginTransaction();
     }
     // turn OFF the log
     self::$logger[self::$counter] = NULL;
     self::setLogger(new TLoggerTXT('log.txt'));
 }