for ($key = dba_firstkey($this->handle); $key !== false; $key = dba_nextkey($this->handle)) { $keyset[] = $key; } // end for
(PHP 4, PHP 5, PHP 7, PHP 8)
dba_firstkey — Lee la primera clave DBA
dba_firstkey() devuelve la primera clave
de la base de datos especificada por handle
y coloca el puntero interno de clave. Esto permitirá recorrer la base.
Devuelve la clave en caso de éxito o false
si ocurre un error.
Versión | Descripción |
---|---|
8.4.0 |
The dba parameter expects a Dba\Connection
instance now; previously, a valid dba resource was expected.
|
for ($key = dba_firstkey($this->handle); $key !== false; $key = dba_nextkey($this->handle)) { $keyset[] = $key; } // end for
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<?phpfunction 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;}?>
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 :-)");