Example #1
0
 /**
  * 重新连接一次数据库
  * 如果 $con_name 相同则不连接
  *
  * @param string|array $con_name
  * @param string $forceReconnect
  */
 public function reconnect($con_name, $forceReconnect = false)
 {
     if (is_array($con_name)) {
         $cfg = $con_name;
     } else {
         $cfg = null;
     }
     if ($forceReconnect || $con_name != $this->getConnName()) {
         if ($this->_debug) {
             Watt_Debug::addInfoToDefault("Watt", "Before connect use Watt_Db.");
         }
         if (class_exists('Propel')) {
             $this->_connection = Propel::getConnection($con_name);
             $this->_conn = $this->_connection->getResource();
             $this->_dsn = $this->_connection->getDSN();
         } else {
             if (!is_array($cfg)) {
                 $configuration = (include Watt_Config::getConfigPath() . "propel.conf.php");
                 $cfg = $configuration['datasources'][$con_name]['connection'];
             }
             $this->_conn = mysql_connect($cfg["hostspec"] . ($cfg["port"] ? ":" . $cfg["port"] : ""), $cfg["username"], $cfg["password"]);
             $this->_dsn = $cfg;
             mysql_select_db($cfg["database"], $this->_conn);
             $charset = @$cfg["charset"] ? $cfg["charset"] : 'utf8';
             mysql_query("set names '{$charset}'");
         }
         $this->setConnName($con_name);
         if ($this->_debug) {
             Watt_Debug::addInfoToDefault("Watt", "After connect [{$con_name}] use Watt_Db.");
         }
     }
 }
 /**
  * @param Connection $dbh
  */
 public function __construct(Connection $conn)
 {
     $this->conn = $conn;
     $this->dblink = $conn->getResource();
     $dsn = $conn->getDSN();
     $this->dbname = $dsn['database'];
 }
Example #3
0
 /**
  * @param Connection $dbh
  */
 public function __construct(Connection $conn, $vendorInfo = array())
 {
     $this->conn = $conn;
     $this->dblink = $conn->getResource();
     $dsn = $conn->getDSN();
     $this->dbname = $dsn['database'];
     $this->vendorSpecificInfo = $vendorInfo;
 }
Example #4
0
 /**
  * 重新连接一次数据库
  * 如果 $con_name 相同则不连接
  *
  * @param string $con_name
  * @param string $forceReconnect
  */
 public function reconnect_old($con_name, $forceReconnect = false)
 {
     if ($forceReconnect || $con_name != $this->getConnName()) {
         if ($this->_debug) {
             Pft_Debug::addInfoToDefault("Pft", "Before connect use Pft_Db.");
         }
         $this->_connection = Propel::getConnection($con_name);
         $this->_conn = $this->_connection->getResource();
         $this->_dsn = $this->_connection->getDSN();
         /*	
         			$configuration = include( Pft_Config::getConfigPath()."propel.conf.php" );
         			$cfg = $configuration['datasources'][$con_name]['connection'];
         			$this->_conn = mysql_connect($cfg["hostspec"].($cfg["port"]?":".$cfg["port"]:""), $cfg["username"], $cfg["password"]);
         			mysql_select_db( $cfg["database"], $this->_conn );
         */
         $this->setConnName($con_name);
         if ($this->_debug) {
             Pft_Debug::addInfoToDefault("Pft", "After connect [{$con_name}] use Pft_Db.");
         }
     }
 }
 /**
  * @see Connection::connect()
  */
 public function getDSN()
 {
     return $this->childConnection->getDSN();
 }
 /**
  * @see Connection::connect()
  */
 public function getDSN()
 {
     krumo('DBArrayConnection getDSN ');
     die;
     return $this->childConnection->getDSN();
 }