PHP 8.3.4 Released!

dba_nextkey

(PHP 4, PHP 5, PHP 7, PHP 8)

dba_nextkeyRecuperar la siguiente clave

Descripción

dba_nextkey(resource $handle): string

dba_nextkey() devuelve la siguiente clave de la base de datos y avanza el apuntador de clave interno.

Parámetros

handle

El gestor de base de datos, devuelto por dba_open() o dba_popen().

Valores devueltos

Devuelve la clave si tiene éxito o false en caso de error.

Ver también

add a note

User Contributed Notes 1 note

up
0
phpnet at araxon dot sk
1 year ago
It should be noted that it is not always safe to iterate through the database while changing it at the same time. For example:

<?php
$db
=dba_open(...);

// remove all values shorter than 10 characters
for ($key=dba_firstkey($db); $key!==false; $key=dba_nextkey($db)) {
$s=dba_fetch($key, $db);
if (
strlen($s)<10) {
dba_delete($key, $db);
}
}
?>

The above example will work fine with db4 handler, but not with gdbm. It is handler specific.
To Top