- 論壇徽章:
- 0
|
[quote]The DBI itself does not mandate or require any particular language to be used; it is language indepe ...
[size=2][color=#999999]akwhole 發(fā)表于 2011-08-03 15:58[/color] [url=http://72891.cn/redirect.php?goto=findpost&pid=21287909&ptid=3576313][img]http://72891.cn/images/common/back.gif[/img][/url][/size][/quote]
意思是說,DBI接口不依賴于具體的數(shù)據(jù)庫類型,它下面有DBD::Oracle, DBD::Mysql來處理這些數(shù)據(jù)庫的差異。
對于DBI來說,它只管把接收到的SQL語句作為一個字符變量,來執(zhí)行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( );
數(shù)據(jù)庫的差異由創(chuàng)建$dbh時,由$dsn指定,到了后面的$sth,就只管執(zhí)行SQL。 |
|