downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

dba_handlers> <dba_fetch
[edit] Last updated: Fri, 10 Feb 2012

view this page in

dba_firstkey

(PHP 4, PHP 5)

dba_firstkey最初のキーを取得する

説明

string dba_firstkey ( resource $handle )

dba_firstkey() はデータベースの最初のキーを返し、 内部キーポインタをリセットします。 この関数によりデータベース全体を連続的にサーチすることが可能になります。

パラメータ

handle

dba_open() あるいは dba_popen() によって返されたデータベースハンドル。

返り値

成功した場合にキー、失敗した場合に FALSE を返します。

参考



dba_handlers> <dba_fetch
[edit] Last updated: Fri, 10 Feb 2012
 
add a note add a note User Contributed Notes dba_firstkey
rcracer91 at gmail dot com 26-Aug-2009 12:21
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;
}
?>
psycho-logic at excite dot com 22-Oct-2003 05:38
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 :-)");
jacky dot jackyhung dot net 17-Jan-2002 05:17
for ($key = dba_firstkey($this->handle); $key !== false; $key = dba_nextkey($this->handle)) {
            $keyset[] = $key;
        } // end for

 
show source | credits | stats | sitemap | contact | advertising | mirror sites