#23919 [Opn->Bgs]: DBA_firstkey and nextkey do not work properly

From: Date: Sat, 31 May 2003 12:09:37 +0000
Subject: #23919 [Opn->Bgs]: DBA_firstkey and nextkey do not work properly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-40777@lists.php.net to get a copy of this message
ID: 23919 Updated by: helly@php.net Reported By: the dot vinculum at gmx dot de -Status: Open +Status: Bogus Bug Type: DBM/DBA related Operating System: Linux PHP Version: 4.3.2 New Comment: Reread the manual. Your code has at least two major problems: 1) dba_firstkey/dba_nextkey return either the value or false. That means you must check with "=== false" not "== false". 2) You have an if statement with dba_nextkey and then do another nextkey which means that you are skipping entries here. And then your code does not make any sense at all since you do net read the values. Previous Comments: ------------------------------------------------------------------------ [2003-05-31 06:05:28] the dot vinculum at gmx dot de Hello, I encountered a bug while working with the DBA Databse (well i guess thats a bug). I saved Guestbook entries in a DBa because of no support of mySQL at my account. The way it was saved: x.y = Value x= is the integer of the entry, eg 1,2,3,4... y= index of entry, usually to save Name, Title and so on, eg. 1.1, 1.2, 1.3,... Value is just a String. This is just en example later i created a DBA with ips, so the key string is an IP which means that it is unknow to me. Because of this lack of knowledge of the key names i thought to use the firstkey and nextkey functions to search the DB. I tried it at first at my Guestbook DBa = x.y=Value Here is the ineffective code: $id= dba_open ("postings.db", "w", "gdbm"); $str.= dba_firstkey($id)." First Key <br>"; for ($i=1;$i<=200;$i++){ if (dba_nextkey($id)==false){ $str.="$i = False<BR>";} else { $str.= dba_nextkey($id)."<br>";} } echo $str; dba_close($id); I know it is ineffective i used the for loop to make sure that it doenst stops too early . Fact is that this loop began at 6.3, what is completly nonsense, that is eiter the first key, nor the last. And i realized that this way to list them does not show all entries, even not the first 1.1. I guess thats a very big bug, because it makes it impossible to work with the DBA properly. I hope this description helps you to fix this bug. Samuel ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=23919&edit=1

« previous php.bugs (#40777) next »