PHP 5.4.31 Released

dba_firstkey

(PHP 4, PHP 5)

dba_firstkeyLit la première clé DBA

Description

string dba_firstkey ( resource $handle )

dba_firstkey() retourne la première clé de la base de données spécifiée par handle et y place le pointeur interne de clé. Cela permettra de traverser la base.

Liste de paramètres

handle

Le gestionnaire de base de données, retourné par la fonction dba_open() ou la fonction dba_popen().

Valeurs de retour

Retourne la clé en cas de succès ou FALSE si une erreur survient.

Voir aussi

add a note add a note

User Contributed Notes 3 notes

up
0
rcracer91 at gmail dot com
4 years ago
I wondered why it wasn't already written, so I did because I think working with associative arrays is always as comfortable as can be

<?php
function dba_fetch_assoc($handle) {
   
$assoc = array();
    for(
$k = dba_firstkey($handle); $k != false; $k = dba_nextkey($handle)) {
       
$assoc[$k] = dba_fetch($k, $handle);
    }
    return
$assoc;
}
?>
up
0
psycho-logic at excite dot com
10 years ago
Looks like Jacky is using some DB object? I don't know if it's native to PHP or written on it's own... Anyways this is what I use:

$DBCon = dba_open("/tmp/test_db.db2", "r", "db2") or die("Uh oh, can't open the database :(");
if ($the_key = dba_firstkey($DBCon)) do {
    print("Key: $the_key    Value:");
    print dba_fetch($the_key, $DBCon);
    print("<BR>");
} while ($the_key = dba_nextkey($DBCon));
print ("<BR><BR><BR>Well looks like we're done here :-)");
up
0
jacky dot jackyhung dot net
12 years ago
for ($key = dba_firstkey($this->handle); $key !== false; $key = dba_nextkey($this->handle)) {
            $keyset[] = $key;
        } // end for
To Top