PearDB初心者入門ガイド
15687 ワード
Pear DB
初心者入門ガイド
(原文:『
Quick Start Guide to Pear DB
》)
陳剛
([email protected])
目
録音する
1.
プロフィール----------------------------------------------------------------------------------------------2
2.
Pear-----------------------------------------------------------------------------------------------------2
3
Pear DBを使う---------------------------------------------------------------------------------------------------2
3.1.1
接続、データベースの切断
3.1.2
データベースの実行
3.1.3
取得
select
のデータ
3.1.3.1
データを取得する関数
3.1.3.2
取得データのフォーマットの選択
3.1.3.3
取得データのフォーマットの設定
3.1.3.4
取得データ数の制御
3.1.3.5
結果をクリアし、変数を解放
3.1.4
すばやく
retrieve
データ#データ#
3.1.5
クエリー結果からの詳細情報
(numRows, numCols, affectedRows, tableInfo)
3.1.6
自動成長(
Sequences
)
3.1.7
Prepare & Execute/ExcuteMultiple
3.1.8
autoCommit, commit and rollback
4.
利用可能な方法の一覧----------------------------------------------------------------------------------------------------------------------------------------------10
5
エラー処理メカニズム---------------------------------------------------------------------------------------12
5.1
から
Pear DB Error
エラーメッセージの取得
5.2
Debug Pear DB Errors
5.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
例:
PHP CVSの完全ドキュメントを入手
に注意
Pear DB
必須
PHP
バージョン#バージョン#
4.0.4
以上である.
Pear
その他のパッケージは次のとおりです.
XML Parser of the pear installer scrīpt
必要
PHP4.0.5
以上のバージョン.
3.
使用
Pear DB
3.1
接続、データベースの切断
データソース
(
前例の
$dsn
パラメータ
)
次のフォーマットを使用できます.(
Pear/DB.php
の
parseDSN
メソッドのコピー
初心者入門ガイド
(原文:『
Quick Start Guide to Pear DB
》)
陳剛
([email protected])
目
録音する
1.
プロフィール----------------------------------------------------------------------------------------------2
2.
Pear-----------------------------------------------------------------------------------------------------2
3
Pear DBを使う---------------------------------------------------------------------------------------------------2
3.1.1
接続、データベースの切断
3.1.2
データベースの実行
3.1.3
取得
select
のデータ
3.1.3.1
データを取得する関数
3.1.3.2
取得データのフォーマットの選択
3.1.3.3
取得データのフォーマットの設定
3.1.3.4
取得データ数の制御
3.1.3.5
結果をクリアし、変数を解放
3.1.4
すばやく
retrieve
データ#データ#
3.1.5
クエリー結果からの詳細情報
(numRows, numCols, affectedRows, tableInfo)
3.1.6
自動成長(
Sequences
)
3.1.7
Prepare & Execute/ExcuteMultiple
3.1.8
autoCommit, commit and rollback
4.
利用可能な方法の一覧----------------------------------------------------------------------------------------------------------------------------------------------10
5
エラー処理メカニズム---------------------------------------------------------------------------------------12
5.1
から
Pear DB Error
エラーメッセージの取得
5.2
Debug Pear DB Errors
5.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:[email protected]:/repository login
pear , 。 :"today", "last month", 。 "last week" , bugs 。
# cvs -d :pserver:[email protected]:/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 scrīpt
必要
PHP4.0.5
以上のバージョン.
3.
使用
Pear DB
3.1
接続、データベースの切断
// 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
部分
):
|
注意并不是所有数据库特征都支持,可以从
根目录
>/DB/STATUS
得到详细的清单。
3.2
执行数据库
|