2. 下載、安裝Pear 由于現在Pear項目仍處于緊鑼密鼓的開發之中,所以得到它的最好辦法就是從C " /> 99精品免费观看,国产亚洲欧美高清在线,7777色鬼xxxx欧美色夫

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

Pear DB 新手入門指南教程第1/3頁

1. 簡介這是一部指導我們如何使用Pear DB擴展。Pear DB,提供這樣一系列的類:
n 數據庫抽象
n 高級錯誤處理機制
n 以及其它

2. 下載、安裝Pear
由于現在Pear項目仍處于緊鑼密鼓的開發之中,所以得到它的最好辦法就是從CVS獲得(Pear DB發行包已經跟隨php4.0.6以后版本捆綁發布)。所以,我們只需要把Pear的根目錄放到php.ini配置文件include_path中。也可以通過這樣設置:_set('include_path', '/pear_base_dir').

以下是strp by step示例:

存放Pear的目錄:
# cd /usr/local/lib
用“phpfi“口令登錄:
# cvs -d :pserver:cvsread@cvs.php.NET:/repository login
用以下命令得到所有的pear文件,同時也可以用來更新已經下載的文件。其他的參數有:"today", "last month",等。我推薦用"last week"參數,因為一般bugs的提交和修改都是每周一次。 
# cvs -d :pserver:cvsread@cvs.php.NET:/repository export -D "last week" php4/pear
編輯php.ini文件加上下面一段在include_path處: /usr/local/lib/php4/pear 如果沒有修改的權限,可以通過這條語句在代碼中實現: ini_set('include_path', 'path_to_pear');

獲得php CVS的完全文檔

注意Pear DB必需php版本4.0.4以上,而在Pear中的一些其他包如:XML Parser of the pear installer script需要php4.0.5以上版本。

 

3.        使用Pear DB

3.1         連接,斷開數據庫

 
<?php
// The pear base directory must be in your include_path
require_once 'DB.php';
$user 'foo';
$pass 'bar';
$host 'localhost';
$db_name 'clients_db';

// Data Source Name: This is the universal connection string
$dsn "mysql://$user:$pass@$host/$db_name";

// DB::connect will return a Pear DB object on success
// or a Pear DB Error object on error
// You can also set to TRUE the second param
// if you want a persistent connection:
// $db = DB::connect($dsn, true);
$db DB::connect($dsn);

// With DB::isError you can differentiate between an error or
// a valid connection.
if (DB::isError($db)) {
        die ($db->getMessage());
}
....
// You can disconnect from the database with:
$db->disconnect();
?>
 

數據源(上例中的$dsn 參數)有以下允許的格式:(從Pear/DB.php的parseDSN方法復制而來)

 
     *  phptype: Database backend used in php (mysql, odbc etc.)
     *  dbsyntax: Database used with regards to SQL syntax etc.
     *  protocol: Communication protocol to use (tcp, unix etc.)
     *  hostspec: Host specification (hostname[:port])
     *  database: Database to use on the DBMS server
     *  username: User name for login
     *  password: Password for login
     *
     * The format of the supplied DSN is in its fullest form:
     *
     *  phptype(dbsyntax)://username:password@protocol+hostspec/database
     *
     * Most variations are allowed:
     *
     *  phptype://username:password@protocol+hostspec:110//usr/db_file.db
     *  phptype://username:password@hostspec/database_name
     *  phptype://username:password@hostspec
     *  phptype://username@hostspec
     *  phptype://hostspec/database
     *  phptype://hostspec
     *  phptype(dbsyntax)
     *  phptype

現在支持的數據庫有 (在 phptype DSN 部分):

 
mysql  -> MySQL
pgsql  -> PostgreSQL
ibase  -> InterBase
msql   -> Mini SQL
mssql  -> Microsoft SQL Server
oci8   -> Oracle 7/8/8i
odbc   -> ODBC (Open Database Connectivity)
sybase -> SyBase
ifx    -> Informix
fbsql  -> FrontBase

注意并不是所有數據庫特征都支持,可以從根目錄>/DB/STATUS 得到詳細的清單。

3.2         執行數據庫

 
<?php
// Once you have a valid DB object
...
$sql "select * from clients";
// If the query is a "SELECT", $db->query will return
// a DB Result object on success.
// Else it simply will return a DB_OK
// On failure it will return a DB Error object.
$result $db->query($sql);
// Always check that $result is not an error
if (DB::isError($result)) {
        die ($result->getMessage());
}
....
?>
 

 

3.3         獲得select的數據

php技術Pear DB 新手入門指南教程第1/3頁,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产偷抇久久精品A片蜜臀AV | 欧美videos人牛交 | 欧美精品色婷婷五月综合 | 国产成人h在线视频 | 亚洲日本在线不卡二区 | 伊人影院香蕉久在线26 | 国产成人精品综合在线 | 丰满人妻按磨HD | 高H高肉强J短篇校园 | 女教师二十三岁 | 好男人WWW免费高清视频在线 | 无码日本亚洲一区久久精品 | 97在线观看免费 | 2012中文字幕手机在线 | 美国ZOOM动物在线观看 | 青青草久久伊人 | 色爱区综合激情五月综合激情 | 国产精品亚洲电影久久成人影院 | 秋霞网韩国理伦片免费看 | 国产精品视频在线自在线 | 中文字幕人成人乱码亚洲影视S | 亚洲中文久久久久久国产精品 | 精品国产品国语在线不卡丶 | 精品视频免费在线 | 亚洲精品中文字幕制 | 中文字幕在线视频免费观看 | 精品欧美一区二区三区久久久 | 九九热免费在线观看 | 丰满的寡妇hd高清在线观看 | 69夫妻交友网| 国产精品午夜小视频观看 | 久9视频这里只有精品123 | www伊人网 | 苍井空a 集在线观看网站 | 99热这里只有 精品 99热这里只就有精品22 | 国产人妻人伦精品熟女麻豆 | 午夜伦理yy44008影院 | 欧美人与动牲交ZOOZ特 | 久久精品WWW人人爽人人 | 久久网站视频 | 国产在线精品一区二区在线看 |