本文整理汇总了PHP中Connection::getDSN方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getDSN方法的具体用法?PHP Connection::getDSN怎么用?PHP Connection::getDSN使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::getDSN方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reconnect
/**
* 重新连接一次数据库
* 如果 $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.");
}
}
}
示例2: __construct
/**
* @param Connection $dbh
*/
public function __construct(Connection $conn)
{
$this->conn = $conn;
$this->dblink = $conn->getResource();
$dsn = $conn->getDSN();
$this->dbname = $dsn['database'];
}
示例3: __construct
/**
* @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;
}
示例4: reconnect_old
/**
* 重新连接一次数据库
* 如果 $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.");
}
}
}
示例5: getDSN
/**
* @see Connection::connect()
*/
public function getDSN()
{
return $this->childConnection->getDSN();
}
示例6: getDSN
/**
* @see Connection::connect()
*/
public function getDSN()
{
krumo('DBArrayConnection getDSN ');
die;
return $this->childConnection->getDSN();
}