When you need to deal with big amounts of data, MySQL is not a good solution. db4 is much faster and easier – you don’t need any SQL queries to extract the necessary values and use them. The process of db4 file creation is quite easy; you need to have your PHP compiled with dba support. If you don’t know how to do it, you can find it on my blog: dba support for PHP
If you have a text file, you need to have your values arranged. The best way to do this is to start each key-value pair with a new line. This way you will easily explode your strings into little arrays and then add them to your db4 database. The code is here:
$id =dba_open( './baza.db' , 'c' , 'cdb' ); |
$id =dba_open( './baza.db' , 'w' , 'db4' ); |
$positions = array ( 'some key' => 'some value' ); |
foreach ( $positions as $key => $value ) |
dba_insert( $key , $value , $id ); |
We have created a db4 file that should have bigger size than the initial text file. Next time I will show you how to access your db4 file and how to extract values from it.