您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

写了一个设置pdo DSN的方法想请大家看看_PHP教程

2024/2/29 11:49:14发布24次查看
写了一个设置pdo dsn的方法想请大家看看
oracle跟sqlite 都只有数据库主机,连数据库名都没有,我不知道怎么设置。
发出来大家看看吧 private function setdsn()
{
switch (strtoupper($this->datatype)){
case 'mysql':
$_dsn = 'mysql:host='.$this->hostname.';dbname='.$this->database.';port='.$this->hostport;
break;
case 'mssql':
case 'db2':
$_dsn = 'dblib:host='.$this->hostname.':'.$this->hostport.';dbname='.$this->database;
break;
case 'oracle':
$_tns =
(description =
(address_list =
(address = (protocol = tcp )(host = $this->hostname)(port = $this->hostport))
)
(connect_data =
(service_name = $this->database)
)
);
$_dsn = 'oci:dbname='.$_tns;
break;
case 'sqlite':
$_dsn = 'sqlite:'.$this->hostname;
break;
case 'pgsql':
$_dsn = 'pgsql:host='.$this->hostname.'port='.$this->hostport.';dbname='.$this->database;
break;
case 'firebird':
$_dsn = 'firebird:dbname='.$this->hostname.':'.$this->database;
break;
case 'odbc':
$_dsn = 'odbc:dsn='.$this->hostname.';uid='.$this->username.';pwd='.$this->password;
break;
}
return $_dsn;
}
复制代码oracle 看了一下cn.php.net上的又修改了一下。
[ ]
我来回答
d8888d回贴内容-------------------------------------------------------
我是来学习的[img]http://www.111cn.cn/bbs/images/smilies/default/lol.gif[/img]
d8888d回贴内容-------------------------------------------------------
分少的原因?怎么没人回复呢`
d8888d回贴内容-------------------------------------------------------
见过
d8888d回贴内容-------------------------------------------------------
这两个数据库 都木用过
d8888d回贴内容-------------------------------------------------------
学习一下,只看程序思路,不看用啥数据库
d8888d回贴内容-------------------------------------------------------
请查阅手册上相关的资料
example#1 pdo_sqlite dsn examples
the following examples show pdo_sqlite dsn for connecting to sqlite databases: sqlite:/opt/databases/mydb.sq3
sqlite::memory:
sqlite2:/opt/databases/mydb.sq2
sqlite2::memory:
复制代码
cursade at hotmail dot com
2006-04-21 14:29
if oracle and oracle instant client has been installed,
without db in the same host
for unix/linux,set $ld_library_path
appent your instant client path and client/lib path to it,
for windows set path like this
after set the path ,set tns_admin everioment ,point to
where tnsnames.ora located.
then,you can use service name to connect to your database
test coding
exec(insert into al_module (al_modulename, al_modulefile) values ('$name', '$file'));
?>
复制代码cursade at hotmail dot com
2006-04-20 17:43
if instant client has been installed but the full oracle client
not yet ,you can use pdo to connect to oracle database
like following coding:
getmessage());
}
?>
复制代码
1、sqlite不是数据主机,而是数据库文件
2、oracel的主机格式可能有多种形式,说不定人家是一个数据集群呢?
[ ]
http://www.bkjia.com/phpjc/632606.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/632606.htmltecharticle写了一个设置pdo dsn的方法想请大家看看 oracle跟sqlite 都只有数据库主机,连数据库名都没有,我不知道怎么设置。 发出来大家看看吧 priv...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product