[PHP-DEV] Strange results with dba_* under Berkeley DB2 From: Yusuf Goolamabbas (yusufg <email protected>)
Date: 08/13/99

System: Redhat 6.0/Linux 2.2.5
Apache 1.3.6/PHP 3.0.12 compiled with mysql and BerkeleyDB 2.7.5

I ran tests/dba.php and everything works out smoothly

I break the tests into two programs (see attachments)
1) Adds a few records and traverses the records
2) Just traverses the records and prints the count

I expected that the output from 1 would match 2, however if the
number of records is less than <1000 it doesn't seem to match

Would appreciate insights from developers on this

<?php
  
$id = dba_open("foo.db","n","db2",0600);
if(!$id) {
  die("cannot open db\n");
}
$count = 1000 ;

for($i = 0; $i < $count; $i++)
         if(!dba_replace($i, "test$i.val", $id))
         die( "dba_replace failed for $i\n");

         echo "Added $i entries\n" ;

                  echo "traversing\n";
         $n = 0;
         for($key = dba_firstkey($id); $key != false; $key = dba_nextkey($id))
         $n++;

                  if($n != $count)
         die ("db broken: $n entries, $count expected\n");
         
         dba_close($id);

?>

<?php
$id = dba_open("foo.db","r","db2",0600);
if(!$id) {
  die("cannot open db\n");
}
$n = 0 ;
for( $key = dba_firstkey($id); $key != false ; $key = dba_nextkey($id))
  $n++ ;
  
print "$n\n" ;

dba_close($id);

?>

-- 
Yusuf Goolamabbas
yusufg <email protected>

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>