1
0
mirror of https://github.com/php/doc-ja.git synced 2026-03-23 22:52:11 +01:00
Files
archived-doc-ja/reference/dba/examples.xml
2026-01-18 22:40:46 +00:00

98 lines
2.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: b5fce74a6c0760daccc79063279e102873be6d77 Maintainer: takagi Status: ready -->
<!-- CREDITS: hirokawa -->
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="dba.examples">
&reftitle.examples;
<section xml:id="dba.example">
<title>基本的な例</title>
<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>
<simpara>
DBA はバイナリセーフであり、いかなる制限も受けません。しかし、
使用するデータベースの実装による全ての制約を継承します。
</simpara>
<simpara>
全てのファイルベースのデータベースは、完全に使用可能なものについて
新規に作成されたデータベースのファイルモードを設定する手段を、
提供する必要があります。
ファイルモードは、通常 <function>dba_open</function> または
<function>dba_popen</function> に 4 番目の引数として渡されます。
</simpara>
<simpara>
<function>dba_firstkey</function> および
<function>dba_nextkey</function> 関数を用いて全てのエントリに
連続的にアクセスすることができます。アクセスする際にデータベースを
変更できない可能性があります。
</simpara>
<example>
<title>データベースへのアクセス</title>
<programlisting role="php">
<![CDATA[
<?php
// データベースをオープンする
$key = dba_firstkey($id);
while ($key !== false) {
if (true) { // 他の操作を後で行うためにキーを記憶する
$handle_later[] = $key;
}
$key = dba_nextkey($id);
}
foreach ($handle_later as $val) {
dba_delete($val, $id);
}
?>
]]>
</programlisting>
</example>
</section>
</chapter>
<!-- 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:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->