免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4298 | 回复: 2
打印 上一主题 下一主题

DBI pass-thru mode是什么意思? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-08-03 15:58 |只看该作者 |倒序浏览
The DBI itself does not mandate or require any particular language to be used; it is language independent. In ODBC terms, the DBI is in "pass-thru" mode, although individual drivers might not be. The only requirement is that queries and other statements must be expressed as a single string of characters passed as the first argument to the "prepare" or "do" methods.

RT。

In ODBC terms, the DBI is in "pass-thru" mode, although individual drivers might not be.

这句不知道在说什么?求大侠赐教。

CPAN链接:http://search.cpan.org/~timb/DBI/DBI.pm#SYNOPSIS

论坛徽章:
0
2 [报告]
发表于 2011-08-06 21:19 |只看该作者
[quote]The DBI itself does not mandate or require any particular language to be used; it is language indepe ...
[size=2][color=#999999]akwhole 发表于 2011-08-03 15:58[/color] [url=http://bbs.chinaunix.net/redirect.php?goto=findpost&pid=21287909&ptid=3576313][img]http://bbs.chinaunix.net/images/common/back.gif[/img][/url][/size][/quote]


    意思是说,DBI接口不依赖于具体的数据库类型,它下面有DBD::Oracle, DBD::Mysql来处理这些数据库的差异。

对于DBI来说,它只管把接收到的SQL语句作为一个字符变量,来执行prepare和do操作。
my $dsn = "dbi:Oracle:$tns";
my $dbh = DBI->connect( $dsn, $user, $passwd, {RaiseError => 0} );
    my $sql = "SELECT version FROM product_component_version WHERE product LIKE '%Oracle%' ";
    my $sth = $dbh->prepare( $sql );
    $sth->execute( );

数据库的差异由创建$dbh时,由$dsn指定,到了后面的$sth,就只管执行SQL。

论坛徽章:
0
3 [报告]
发表于 2011-08-07 11:01 |只看该作者
回复 3# jjqing


    讲的很详细,多谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP