/**
  * 返回工厂实例,单例模式
  */
 public static function factory($driver = null, $tableName = null)
 {
     //只实例化一个对象
     if (is_null(self::$dbFactory)) {
         self::$dbFactory = new dbFactory();
     }
     if (is_null($driver)) {
         $driver = ucfirst(strtolower(C("DB_DRIVER")));
     }
     if (is_null($tableName)) {
         $tableName = 'empty';
     }
     if (isset(self::$dbFactory->driverList[$tableName])) {
         return self::$dbFactory->driverList[$tableName];
     }
     self::$dbFactory->getDriver($driver, $tableName);
     return self::$dbFactory->driverList[$tableName];
 }
 /**
  * 返回工厂实例,单例模式
  * @param $driver 连接驱动
  * @param $table 表
  * @param bool $full 加表前缀
  * @return bool
  */
 public static function factory($driver, $table, $full)
 {
     //只实例化一个对象
     if (is_null(self::$dbFactory)) {
         self::$dbFactory = new dbFactory();
     }
     if (is_null($driver)) {
         $driver = ucfirst(C("DB_DRIVER"));
     }
     //数据库驱动存在并且数据库连接正常
     if (isset(self::$dbFactory->driverList[$table]) && self::$dbFactory->driverList[$table]->link) {
         return self::$dbFactory->driverList[$table];
     }
     //获得数据库驱动
     if (self::$dbFactory->getDriver($driver, $table, $full)) {
         return self::$dbFactory->driverList[$table];
     } else {
         return false;
     }
 }
Exemple #3
0
Fichier : Boot.php Projet : jyht/v5
 public static function factory($driver = null, $tableName = null)
 {
     if (is_null(self::$dbFactory)) {
         self::$dbFactory = new dbFactory();
     }
     if (is_null($driver)) {
         $driver = ucfirst(strtolower(C("DB_DRIVER")));
     }
     if (is_null($tableName)) {
         $tableName = 'empty';
     }
     if (isset(self::$dbFactory->driverList[$tableName]) && self::$dbFactory->driverList[$tableName]->link) {
         return self::$dbFactory->driverList[$tableName];
     }
     if (self::$dbFactory->getDriver($driver, $tableName)) {
         return self::$dbFactory->driverList[$tableName];
     } else {
         return false;
     }
 }