1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.11 $ -->
<reference id="ref.dba">
<title>(dbm型の)データベース・アブストラクション レイヤー関数</title>
<titleabbrev>dba</titleabbrev>
<partintro>
<para>
これらの関数は、Berkeley DB 型データベースへのアクセス用の基本関数を
構成します。
</para>
<para>
これらの関数は、複数のファイルベースのデータベース用のアブストラクション
・レイヤーです。その機能は、<ulink url="&url.sleepycat;">Sleepycat
Software's DB2</ulink>サポートのような近代的なデータベースの機能の
サブセットに制限されています。(IBMのソフトウエアDB2と混同しないで
下さい。このデータベースは、<link linkend="ref.odbc">ODBC 関数
</link>を通じてサポートされます。)
</para>
<para>
各機能の動作は、使用するデータベースの実装に依存します。
<function>dba_optimize</function> および <function>dba_sync</function> の
ような関数は使用するデータベースに依存したことを行い、他のデータベース
用の機能は実行しません。
</para>
<para>
<function>dba_open</function>または<function>dba_popen</function>
関数を実行する際、以下のハンドラの1つを引数として指定する必要があ
ります。実際に利用可能茄ハンドラのリストは、
<function>phpinfo</function>を実行した際に表示されます。(PHPの作成
時に以下のハンドラのどれかのサポートを追加するには、PHPのconfigure
にスイッチ<literal>--with-XXXX</literal> の指定を追加して下さい。
<table>
<title>DBAハンドラのリスト</title>
<tgroup cols="2">
<thead>
<row>
<entry>ハンドラ</entry>
<entry>注意</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>dbm</literal></entry>
<entry>
dbm は最も古い(元祖の)Berkeley DB 型データベースです。可能なら
ば使用しない方が良いでしょう。DB2およびgdbmに組み込まれている互
換性を保つための関数は、サポートされません。これは、実装されて
いるのがソースレベルの互換性のみであり、元のdbmフォーマットを処
理することができないためです。(<literal>--with-dbm</literal>)
</entry>
</row>
<row>
<entry><literal>ndbm</literal></entry>
<entry>
ndbm は、より新型であり、dbmよりも柔軟です。
dbm固有の制約の多くをまだ有しています。(そのため、古い実装です。)
(<literal>--with-ndbm</literal>)
</entry>
</row>
<row>
<entry><literal>gdbm</literal></entry>
<entry>
gdbmは、<ulink url="&url.gdbm;">GNUデータベースマネージャ
</ulink>です。(<literal>--with-gdbm</literal>)
</entry>
</row>
<row>
<entry><literal>db2</literal></entry>
<entry>
DB2 は、<ulink url="&url.sleepycat;">Sleepycat Software's DB2</ulink>
です。これは、「スタンドアローンおよびクライアント/サーバー
アプリケーションの両方で高性能な組込みデータベースサポートを提供する
プログラム用ツールキット」として記述されています。
(<literal>--with-db2</literal>)
</entry>
</row>
<row>
<entry><literal>db3</literal></entry>
<entry>
DB3 は、<ulink url="&url.sleepycat;">Sleepycat Softwareの
DB3</ulink>です。(<literal>--with-db3</literal>)
</entry>
</row>
<row>
<entry><literal>cdb</literal></entry>
<entry>
cdbは、固定データベースの作成・読込み用の高速で高信頼性の軽量型
パッケージです。これは、qmailの作者によるものであり、<ulink
url="&url.cdb;">ここ</ulink>にあります。固定であるため、読込
み操作のみがサポートされます。(<literal>--with-cdb</literal>)
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<example>
<title>DBAの例</title>
<programlisting role="php">
<![CDATA[
<?php
$id = dba_open ("/tmp/test.db", "n", "db2");
if (!$id) {
echo "dba_open failed\n";
exit;
}
dba_replace ("key", "This is an example!", $id);
if (dba_exists ("key", $id)) {
echo dba_fetch ("key", $id);
dba_delete ("key", $id);
}
dba_close ($id);
?>
]]>
</programlisting>
</example>
</para>
<para>
DBAは、バイナリセーフでありいかなる制限も受けません。
DBA は、使用するデータベースの実装による全ての制約を継承します。
</para>
<para>
全てのファイルベースのデータベースは、完全に使用可能なものについて
新規に作成されたデータベースのファイルモードを設定する手段を、
提供する必要があります。
ファイルモードは、通常 <function>dba_open</function> または
<function>dba_popen</function> に4番目の引数として渡されます。
</para>
<para>
<function>dba_firstkey</function> および <function>dba_nextkey</function>
関数を用いて連続的に全てのエントリにアクセスすることができます。
アクセスする際にデータベースを変更できない可能性があります。
</para>
<para>
<example>
<title>データベースへの連続アクセス</title>
<programlisting role="php">
<![CDATA[
<?php
# ...データベースをオープンする...
$key = dba_firstkey ($id);
while ($key != false) {
if (...) { # 他の操作を後で行うためにキーを記憶する
$handle_later[] = $key;
}
$key = dba_nextkey ($id);
}
for ($i = 0; $i < count($handle_later); $i++)
dba_delete ($handle_later[$i], $id);
?>
]]>
</programlisting>
</example>
</para>
</partintro>
<refentry id="function.dba-close">
<refnamediv>
<refname>dba_close</refname>
<refpurpose>データベースを閉じる</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>void</type><methodname>dba_close</methodname>
<methodparam><type>int</type><parameter>handle</parameter></methodparam>
</methodsynopsis>
<para>
<function>dba_close</function>は使用するデータベースを閉じ、
<parameter>handle</parameter>により指定した全てのリソースを
開放します。
</para>
<para>
<parameter>handle</parameter>は、<function>dba_open</function>により
返されたデータベースハンドルです。
</para>
<para>
<function>dba_close</function>は値を返しません。
</para>
<para>
<function>dba_open</function>、
<function>dba_popen</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.dba-delete">
<refnamediv>
<refname>dba_delete</refname>
<refpurpose>キーが指すエントリを削除する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>bool</type><methodname>dba_delete</methodname>
<methodparam><type>string</type><parameter>key</parameter></methodparam>
<methodparam><type>int</type><parameter>handle</parameter></methodparam>
</methodsynopsis>
<para>
<function>dba_delete</function> は、<parameter>handle</parameter>
が指すデータベースから <parameter>key</parameter> が指すエントリを
削除します。
</para>
<para>
<parameter>key</parameter>は削除するエントリのキーです。
</para>
<para>
<parameter>handle</parameter> は、<function>dba_open</function>により
返されたデータベースハンドルです。
</para>
<para>
<function>dba_delete</function> は、エントリが削除または削除されない
場合にそれぞれ&true;または&false;を返します。
</para>
<para>
<function>dba_exists</function>,
<function>dba_fetch</function>,
<function>dba_insert</function>,
<function>dba_replace</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.dba-exists">
<refnamediv>
<refname>dba_exists</refname>
<refpurpose>キーが存在するかどうかを確認する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>bool</type><methodname>dba_exists</methodname>
<methodparam><type>string</type><parameter>key</parameter></methodparam>
<methodparam><type>int</type><parameter>handle</parameter></methodparam>
</methodsynopsis>
<para>
<function>dba_exists</function>は<parameter>handle</parameter>
が指すデータベースに指定した
<parameter>key</parameter>が存在するかどうかを確認します。
</para>
<para>
<parameter>key</parameter>は確認を行うキーです。
</para>
<para>
<parameter>handle</parameter>は、<function>dba_open</function>により
返されたデータベースハンドルです。
</para>
<para>
<function>dba_exists</function>はキーがある場合に&true;,見つからな
い場合に&false;を返します。
</para>
<para>
<function>dba_fetch</function>、
<function>dba_delete</function>、
<function>dba_insert</function>、
<function>dba_replace</function> も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.dba-fetch">
<refnamediv>
<refname>dba_fetch</refname>
<refpurpose>キーが指すデータを取得する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>string</type><methodname>dba_fetch</methodname>
<methodparam><type>string</type><parameter>key</parameter></methodparam>
<methodparam><type>int</type><parameter>handle</parameter></methodparam>
</methodsynopsis>
<para>
<function>dba_fetch</function>は、<parameter>handle</parameter>
が指すデータベースから<parameter>key</parameter>が指すデータを取
得します。
</para>
<para>
<parameter>key</parameter>はデータを取得するキーです。
</para>
<para>
<parameter>handle</parameter>は、<function>dba_open</function>により
返されたデータベースハンドルです。
</para>
<para>
<function>dba_fetch</function> はキー/データの組が見つかった場合に
取得した文字列、見つからなかった場合に&false;を返します。
</para>
<para>
<function>dba_exists</function>、
<function>dba_delete</function>、
<function>dba_insert</function>、
<function>dba_replace</function> も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.dba-firstkey">
<refnamediv>
<refname>dba_firstkey</refname>
<refpurpose>最初のキーを取得する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>string</type><methodname>dba_firstkey</methodname>
<methodparam><type>int</type><parameter>handle</parameter></methodparam>
</methodsynopsis>
<para>
<function>dba_firstkey</function>は、<parameter>handle</parameter>が
指すデータベースの最初のキーを返し、内部キーポインタをリセットします。
この関数によりデータベース全体を連続的にサーチすることが可能になります。
</para>
<para>
<parameter>handle</parameter>は、<function>dba_open</function>により
返されたデータベースハンドルです。
</para>
<para>
<function>dba_firstkey</function>は成功した場合にキーを、失敗した場合に
&false;を返します。
</para>
<para>
<function>dba_nextkey</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.dba-insert">
<refnamediv>
<refname>dba_insert</refname>
<refpurpose>エントリを挿入する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>bool</type><methodname>dba_insert</methodname>
<methodparam><type>string</type><parameter>key</parameter></methodparam>
<methodparam><type>string</type><parameter>value</parameter></methodparam>
<methodparam><type>int</type><parameter>handle</parameter></methodparam>
</methodsynopsis>
<para>
<function>dba_insert</function>は、<parameter>handle</parameter>
が指すデータベースに<parameter>key</parameter> および
<parameter>value</parameter>で記述されるエントリを挿入します。
同じ<parameter>key</parameter>が既に存在する場合に失敗します。
</para>
<para>
<parameter>key</parameter>は、挿入するエントリのキーです。
</para>
<para>
<parameter>value</parameter>は、挿入するエントリの値です。
</para>
<para>
<parameter>handle</parameter>は、<function>dba_open</function>に
より返されたデータベースハンドルです。
</para>
<para>
<function>dba_insert</function>は成功時に&true;、失敗した場合に&false;を
返します。
</para>
<para>
<function>dba_exists</function>
<function>dba_delete</function>
<function>dba_fetch</function>
<function>dba_replace</function> も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.dba-nextkey">
<refnamediv>
<refname>dba_nextkey</refname>
<refpurpose>次のキーを取得する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>string</type><methodname>dba_nextkey</methodname>
<methodparam><type>int</type><parameter>handle</parameter></methodparam>
</methodsynopsis>
<para>
<function>dba_nextkey</function> は、<parameter>handle</parameter>
が指すデータベースのキーを返し、内部ポインタを進めます。
</para>
<para>
<parameter>handle</parameter>は、<function>dba_open</function> により
返されたデータベースハンドルです。
</para>
<para>
<function>dba_nextkey</function> は成功時にキーを、失敗した場合に
&false;を返します。
</para>
<para>
<function>dba_firstkey</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.dba-popen">
<refnamediv>
<refname>dba_popen</refname>
<refpurpose>データベースを持続的にオープンする</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>int</type><methodname>dba_popen</methodname>
<methodparam><type>string</type><parameter>path</parameter></methodparam>
<methodparam><type>string</type><parameter>mode</parameter></methodparam>
<methodparam><type>string</type><parameter>handler</parameter></methodparam>
<methodparam><type></type><parameter>
<replaceable><optional>...</optional></replaceable>
</parameter></methodparam>
</methodsynopsis>
<para>
<function>dba_popen</function> は、 <parameter>handler</parameter>
を用いて<parameter>mode</parameter>で<parameter>path</parameter>
への持続的データベースインスタンスを確立します。
</para>
<para>
<parameter>path</parameter> は、通常のファイルシステムのパスです。
</para>
<para>
<parameter>mode</parameter> には、既存のデータベースにアクセスする
際に読み込みアクセス用に "r"、読込み/書き込みアクセス用に"w"を、
読み込み/書き込みアクセスおよび存在しない場合にデータベースの作成をする
ために"c"を、作成、上書き、読込み/書き込みアクセス用に "n" を指定
します。
</para>
<para>
<parameter>handler</parameter> は、<parameter>path</parameter>を
アクセスするために使用するハンドルの名前です。
<function>dba_popen</function> に指定した全てのオプションパラメータを
渡し、そのオプションの機能を用いることができます。
</para>
<para>
<function>dba_popen</function> は、オープンに成功した場合に正の
ハンドラID、失敗した場合に&false;を返します。
</para>
<para>
<function>dba_open</function>、
<function>dba_close</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.dba-open">
<refnamediv>
<refname>dba_open</refname>
<refpurpose>データベースをオープンする</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>int</type><methodname>dba_open</methodname>
<methodparam><type>string</type><parameter>path</parameter></methodparam>
<methodparam><type>string</type><parameter>mode</parameter></methodparam>
<methodparam><type>string</type><parameter>handler</parameter></methodparam>
<methodparam><type></type><parameter>
<replaceable><optional>...</optional></replaceable>
</parameter></methodparam>
</methodsynopsis>
<para>
<function>dba_open</function>は、<parameter>handler</parameter>を用いて
<parameter>mode</parameter>を指定し、<parameter>path</parameter>
へのデータベースインスタンスを確立します。
</para>
<para>
<parameter>path</parameter>は、ファイルシステムの通常のパスです。
</para>
<para>
<parameter>mode</parameter>には、既存のデータベースにアクセスする
際に読み込みアクセス用に "r"、読込み/書き込みアクセス用に"w"を、
読み込み/書き込みアクセスおよび存在しない場合にデータベースの作成をする
ために"c"を、作成、上書き、読込み/書き込みアクセス用に "n" を指定
します。
</para>
<para>
<parameter>handler</parameter> は、<parameter>path</parameter>を
アクセスするために使用するハンドルの名前です。
<function>dba_open</function> に指定した全てのオプションパラメータを
渡し、そのオプションの機能を用いることができます。
</para>
<para>
<function>dba_open</function> は、オープンに成功した場合に正の
ハンドラID、失敗した場合に&false;を返します。
</para>
<para>
<function>dba_popen</function>、
<function>dba_close</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.dba-optimize">
<refnamediv>
<refname>dba_optimize</refname>
<refpurpose>データベースを最適化する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>bool</type><methodname>dba_optimize</methodname>
<methodparam><type>int</type><parameter>handle</parameter></methodparam>
</methodsynopsis>
<para>
<function>dba_optimize</function> は、<parameter>handle</parameter>
により指定されたデータベースを最適化します。
</para>
<para>
<parameter>handle</parameter> は、<function>dba_open</function> により
返されたデータベースハンドルです。
</para>
<para>
<function>dba_optimize</function> は、最適化に成功した場合に&true;,
失敗した場合に&false;を返します。
</para>
<para>
<function>dba_sync</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.dba-replace">
<refnamediv>
<refname>dba_replace</refname>
<refpurpose>エントリを置換または挿入する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>bool</type><methodname>dba_replace</methodname>
<methodparam><type>string</type><parameter>key</parameter></methodparam>
<methodparam><type>string</type><parameter>value</parameter></methodparam>
<methodparam><type>int</type><parameter>handle</parameter></methodparam>
</methodsynopsis>
<para>
<function>dba_replace</function> は、<parameter>handle</parameter>で
指定したデータベースに<parameter>key</parameter> および
<parameter>value</parameter>で記述されるエントリを置換または挿入
します。
</para>
<para>
<parameter>key</parameter>は挿入するエントリのキーです。
</para>
<para>
<parameter>value</parameter> は挿入する値です。
</para>
<para>
<parameter>handle</parameter> は、<function>dba_open</function>により
返されたデータベースハンドルです。
</para>
<para>
<function>dba_replace</function>は成功した場合に&true;,失敗した場合に
&false;を返します。
</para>
<para>
<function>dba_exists</function>
<function>dba_delete</function>
<function>dba_fetch</function>
<function>dba_insert</function> も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.dba-sync">
<refnamediv>
<refname>dba_sync</refname>
<refpurpose>データベースを同期する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>bool</type><methodname>dba_sync</methodname>
<methodparam><type>int</type><parameter>handle</parameter></methodparam>
</methodsynopsis>
<para>
<function>dba_sync</function> は、<parameter>handle</parameter>で
指定したデータベースを同期します。サポートされる場合には、おそらくディスク
への物理的アクセスへのきっかけとなることでしょう。
</para>
<para>
<parameter>handle</parameter> は、<function>dba_open</function> により
返されたデータベースハンドルです。
</para>
<para>
<function>dba_sync</function> は同期が成功した場合に&true;、失敗した場合に
&false;を返します。
</para>
<para>
<function>dba_optimize</function>も参照下さい。
</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
|