this is not really a sample script, but it explains how you can
do something with it.
you can create an instance of a database by creating a new
object.
my $db = blDB->initdb('filename.db');
or if you want to create a new database:
my $newdb = blDB->newdb('filename.db');
you can add a new table by:
my $newTable = blDB->newTable('tablename',0,0);
and add cols like this:
$newTable->addCol('Name', 0, blDB->dbSTR); (dbLONG,
dbINT, dbBYTE will also work ;))
after you added all cols, you must write the table to the
database:
$db->write($newTable);
then load the table (in most cases this is done automatically)
$db->loadTableExt('tablename');
and add some data to it
$db->addRows('tablename', 'contentforCol1'....);
if you supply more arguments than fit into one row, the other
arguments are written into the next row.
for debugging you should use $db->setDebugLevel(x); where
x can be: 0 (no debug messages), 1 (low-level
debugmessages), 2 (high-level debugmessages).
ok, now you want to read from a table:
print each colname:
print "$_," foreach($db->getKeys('tablename'));
get a spezified row (as an array):
print "$_," foreach($db->fetchRow('tablename', ID));
and to load a complete table (with all its rows):
print "$_->{'nameOfCol'} $_->{'nameOfOtherCol'}\n" foreach
($db->fetchTable('tablename'));
so and then there is a defrag-function which sometimes
works and sometimes not :(
because, by adding data, a the database gets bigger and
bigger and is crosslinked, which leads to speed loss, so its
recommended to defragment the db sometimes, but this
fuckin' stuff does not work properly.
(help is welcome (-;)
[black river]
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Logged In: YES
user_id=556913
this is not really a sample script, but it explains how you can
do something with it.
you can create an instance of a database by creating a new
object.
my $db = blDB->initdb('filename.db');
or if you want to create a new database:
my $newdb = blDB->newdb('filename.db');
you can add a new table by:
my $newTable = blDB->newTable('tablename',0,0);
and add cols like this:
$newTable->addCol('Name', 0, blDB->dbSTR); (dbLONG,
dbINT, dbBYTE will also work ;))
after you added all cols, you must write the table to the
database:
$db->write($newTable);
then load the table (in most cases this is done automatically)
$db->loadTableExt('tablename');
and add some data to it
$db->addRows('tablename', 'contentforCol1'....);
if you supply more arguments than fit into one row, the other
arguments are written into the next row.
for debugging you should use $db->setDebugLevel(x); where
x can be: 0 (no debug messages), 1 (low-level
debugmessages), 2 (high-level debugmessages).
ok, now you want to read from a table:
print each colname:
print "$_," foreach($db->getKeys('tablename'));
get a spezified row (as an array):
print "$_," foreach($db->fetchRow('tablename', ID));
and to load a complete table (with all its rows):
print "$_->{'nameOfCol'} $_->{'nameOfOtherCol'}\n" foreach
($db->fetchTable('tablename'));
so and then there is a defrag-function which sometimes
works and sometimes not :(
because, by adding data, a the database gets bigger and
bigger and is crosslinked, which leads to speed loss, so its
recommended to defragment the db sometimes, but this
fuckin' stuff does not work properly.
(help is welcome (-;)
[black river]