Previous section To contents Next section

14.10.2 Tables

The table object is used to store and retrieve information from a table. Table objects are created by the db class. A table object can create a transaction object.

METHOD
Yabu.table.set - Store a record in a table

SYNTAX
mixed set(string key, mixed data);
mixed `[]=(string key, mixed data);

DESCRIPTION
This method stores the contents of data as a record with the name key. If a record with that name already exists, it will be replaced. Records can only be added to the database in write mode.

SEE ALSO
Yabu.table->get, Yabu.table->delete, Yabu.table->list_keys and Yabu.table->purge

METHOD
Yabu.table.get - Fetch a record from a table

SYNTAX
mixed get(string key);
mixed `[](string key);

DESCRIPTION
This method fetches the data associated with the record name key. If a record does not exist, zero is returned.

SEE ALSO
Yabu.table->set, Yabu.table->delete, Yabu.table->list_keys and Yabu.table->purge

METHOD
Yabu.table.list_keys - List the records in a table

SYNTAX
array(string) list_keys();
array(string) _indices();

DESCRIPTION
This method lists all record names in the table.

SEE ALSO
Yabu.table->set, Yabu.table->get, Yabu.table->delete, Yabu.table->purge and Yabu.table->_values

METHOD
Yabu.table._values - Get all the records in a table

SYNTAX
array(mixed) _values();

DESCRIPTION
This method returns all record names in the table.

SEE ALSO
Yabu.table->set, Yabu.table->get, Yabu.table->delete, Yabu.table->purge and Yabu.table->_indices

METHOD
Yabu.table.delete - Delete a record in a table

SYNTAX
void delete(string key);

DESCRIPTION
This method deletes the record with the name key.

SEE ALSO
Yabu.table->set, Yabu.table->get, Yabu.table->list_keys and Yabu.table->purge

METHOD
Yabu.table.purge - Delete a table

SYNTAX
void purge();

DESCRIPTION
This method deletes the whole table and the table files on disk.

SEE ALSO
Yabu.table->set, Yabu.table->get, Yabu.table->list_keys and Yabu.table->delete

METHOD
Yabu.table.transaction - Begin a transaction

SYNTAX
object(transaction) transaction();

DESCRIPTION
A transaction is a sequence of table commands that will be accepted in whole, or not at all. If the program for some reason crashes or makes an abrupt exit during a transaction, the transaction is cancelled.

This method returns a transaction object.

SEE ALSO
Yabu.transaction->commit and Yabu.transaction->rollback

Previous section To contents Next section