PHPのお勉強!

PHP TOP

dba_handlers

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

dba_handlers利用可能なハンドラの一覧を得る

説明

dba_handlers(bool $full_info = false): array

dba_handlers() は、この拡張モジュールにより サポートされる全てのハンドラの一覧を返します。

パラメータ

full_info

結果の全ての情報を表示するかどうかを切り替えます。

戻り値

データベースハンドラの配列を返します。full_infotrue の場合、この配列はハンドラ名をキー、そのバージョンを値とする 連想配列となります。それ以外の場合はハンドラ名を値に持つ数値添字の配列と なります。

注意:

cdb ライブラリが用いられている場合、 cdb および cdb_make が表示されます。

例1 dba_handlers() の例

<?php

echo "Available DBA handlers:\n";
foreach (
dba_handlers(true) as $handler_name => $handler_version) {
// バージョン番号を見やすくする
$handler_version = str_replace('$', '', $handler_version);
echo
" - $handler_name: $handler_version\n";
}

?>

上の例の出力は、 たとえば以下のようになります。

Available DBA handlers:
 - cdb: 0.75, Revision: 1.3.2.3 
 - cdb_make: 0.75, Revision: 1.2.2.4 
 - db2: Sleepycat Software: Berkeley DB 2.7.7: (08/20/99)
 - inifile: 1.0, Revision: 1.6.2.3 
 - flatfile: 1.0, Revision: 1.5.2.4

add a note

User Contributed Notes 1 note

up
1
cbemerine at gmail dot com
15 years ago
A quick way to see which DBA handlers, without version numbers, that have been built into your version of MySQL on your system, use var_dump with dba_handler() as follows:

<?php
var_dump
( "dba_handlers()" );
?>

Many distros build in these DBA Handlers by default:
array(5) { [0]=> string(3) "cdb" [1]=> string(8) "cdb_make" [2]=> string(3) "db4" [3]=> string(7) "inifile" [4]=> string(8) "flatfile" }

using print and pre tags for readability:

array(5) {

[0]=>

string(3) "cdb"

[1]=>

string(8) "cdb_make"

[2]=>

string(3) "db4"

[3]=>

string(7) "inifile"

[4]=>

string(8) "flatfile"

}

Note there are issues with dba_insert and dba_replace without building for either GDBM or QDBM.
Here are two sources for the list of DBA handlers: (http://www.php-editors.com/php_manual/ref.dba.html and http://dewa03.unep.org/manuals/php_manual/ref.dba.html; )

CDBM & CDB compiles have issues with updates, you can read databases and write new database files, but you will be prevented from using dba_replace() and you may have issues with dba_insert().

NDBM & DBM are depreciated.

DB2, DB3 & DB4 (Berkeley DB Sleepycat Software / Oracle) Have read online about issues with dba_replace() and db4 specifically. Make sure you test your installation for correct usage of all DBA functions.

SDBM, TDB, TinyCDB were not listed on most of the sources I have found online. Those DBA handlers and the names of the developers were listed on the QDBM source forge site. How they interact with dba_replace() I do not know. You should be aware of their existence.

GDBM and QDBM are the only other two DBA handlers I am aware of. Both are reported to allow PHP's dba_replace() function to work correctly so either may be an acceptable option. The following three restrictions of traditional DBM are not issues for either GDBM or QDBM: 1) a process can handle only one database; 2) the size of a key and a value is bounded; 3) a database file is sparse.

DBA handler benchmark compares QDBM, GDBM, NDBM, SDBM, TDB, CDB, BDB, QDBM-BT-ASC, QDBM-BT-RND, BDB-BT-ASC, BDB-BT-RND can be found here: (http://qdbm.sourceforge.net/benchmark.pdf);

QDBM seems to offer significant improvements in speed over the other DBA Handlers, test in your environment to verify the results.
To Top