mirror of
https://github.com/php/doc-es.git
synced 2026-03-23 23:12:09 +01:00
99 lines
2.5 KiB
XML
99 lines
2.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: b5fce74a6c0760daccc79063279e102873be6d77 Maintainer: PhilDaiguille Status: ready -->
|
|
<!-- Reviewed: yes Maintainer: PhilDaiguille -->
|
|
<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>Utilización</title>
|
|
<example>
|
|
<title>Ejemplo con DBA</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$id = dba_open("/tmp/test.db", "n", "db2");
|
|
|
|
if (!$id) {
|
|
echo "dba_open ha fallado\n";
|
|
exit;
|
|
}
|
|
|
|
dba_replace("key", "¡Esto es un ejemplo!", $id);
|
|
|
|
if (dba_exists("key", $id)) {
|
|
echo dba_fetch("key", $id);
|
|
dba_delete("key", $id);
|
|
}
|
|
|
|
dba_close($id);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<simpara>
|
|
DBA gestiona datos binarios y no tiene límites arbitrarios.
|
|
Sin embargo, hereda todas las limitaciones definidas por
|
|
la implementación de la base de datos accedida.
|
|
</simpara>
|
|
<simpara>
|
|
Todas las bases de datos basadas en ficheros deben
|
|
proporcionar una forma de definir el modo de fichero de las nuevas
|
|
bases creadas. Este modo se pasa generalmente como cuarto argumento
|
|
de las funciones <function>dba_open</function> o
|
|
<function>dba_popen</function>.
|
|
</simpara>
|
|
<simpara>
|
|
Se puede acceder a todas las entradas de la base de datos de
|
|
forma lineal, utilizando las funciones <function>dba_firstkey</function>
|
|
y <function>dba_nextkey</function>. No se puede modificar la
|
|
base de datos mientras se está leyendo.
|
|
</simpara>
|
|
<example>
|
|
<title>Lectura de una base de datos</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
// ...apertura de la base de datos...
|
|
|
|
$key = dba_firstkey($id);
|
|
|
|
while ($key !== false) {
|
|
if (true) { // se retiene la clave para realizar otras acciones más tarde
|
|
$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
|
|
-->
|