Kahua Release
- Release Note
- Download
- Current Version 1.0.7.3 (2008-05-08)
kahua-web Release
- kahua-webとは
- Release Note
- Download
- Current Version 0.3.1 (2007-06-12)
Security Advisory
Event Log
Documentation
For developers
Site info
Related Site
MySQLドライバー
ダウンロード
必要なもの
- Gauche 0.8.6 以上(DBIはGaucheに統合されました)
- mysql.h
- libmysqlclient
- mysql_configが存在するディレクトリがPATHに含まれている必要があります。
ライセンス
GPL
インストール
% gauche-package install -S root Gauche-dbd-mysql-0.2.2.tgz
説明
dbd.mysqlモジュールはlibmysqlclientを使用します。 あらかじめlibmysqlclientがインストールされている必要があります。
通常、ユーザーが直接dbd.mysqlモジュールをuseすることはありません。
(use dbi) (use gauche.collection) (define driver (dbi-make-driver "mysql"))
上記のように<mysql-driver>のインスタンスを生成し、 以後はこれを使用します。
(define connection (dbi-make-connection driver "username" "password" "db=test"))
(define query (dbi-make-query connection))
(define result-set (dbi-execute-query query "select * from test"))
(define rows
(map (lambda (row) (list (dbi-get-value row 0) (dbi-get-value row 1))) result-set))
[Class] <mysql-query>
[Slot] %execute-proc
dbi-execute-queryで実行されるクロージャーが保持されています。 デフォルトはmysql-query-store-resultです。
dbd.mysqlをuseし、このスロットを調べることで、 実際にどのクロージャーが使われたかを確認することができます。
[Method] dbi-make-connection driver user password option
dbiモジュールのdbi-make-connectionと同様ですが、 optionに指定できるキーは以下だけです。
- host
- db
- unix_socket
- port
- client_flag
キーの意味はlibmysqlclientのmysql_real_connect関数の引数と同様です。
optionはキー=値のペアを&記号で連結した、 URIのquery-stringに類似した形式で指定します。
[Method] dbi-make-query connection option
[Method] dbi-make-query connection
<mysql-query>を生成します。 optionに"mysql-query-use-result"という文字列を指定すると、 mysql_use_resultを呼び出して結果セットを生成します。
optionを指定しないで呼び出すとmysql_store_resultが使われます。 (デフォルト)
mysql_store_resutlとmysql_use_resultの違いについてはMySQLのマニュアルを参照してください。