NAME

XAO::DO::FS::Glue::MySQL - MySQL driver for XAO::FS

SYNOPSIS

Should not be used directly.

DESCRIPTION

Not finished, is being worked on! Unusable.

This module implements some functionality required by XAO::DO::FS::Glue in MySQL specific way.

The advantage of this module over MySQL_DBI is that it does not use DBI and therefore is faster. As XAO::FS has specific drivers for each database anyway it does not make a lot of sense to use DBI.

METHODS

new ($%)

Creates new instance of driver connected to the given $dbh handler. An example:

my $driver=XAO::Objects->new(objname => 'FS::Glue::MySQL',
                             dbh => $dbh);
add_field_text ($$$)

Adds new text field to the given table.

add_reference_fields ($$$)

Adds new key and connector fields to the existing table. Used when secondary reference is created for the same object.

add_table ($$$)

Creates new empty table with unique_id, key and optionally connector fields.

delete_row ($$)

Deletes a row from the given name and unique_id.

drop_field ($$)

Drops the given field from the given table in the database. Whatever content was in that field is lost irrevocably.

empty_field ($$$)

Removes content of given field in the given table by storing NULL in it.

initialize_database ($)

Removes all data from all tables and creates minimal tables that support objects database.

retrieve_field ($$$$)

Retrieves individual field from the given table by unique ID of the row.

search ($table $keyname $c_name $c_value $lha $op $rha)

Searches on single condition in single table and returns a reference to the list of values in the given key field. Even if the list is empty a reference to the empty list is still returned.

Example:

$self->_driver->search($table,$$self->{key_name},
                       $$self->{connector_name},$$self->{base_id},
                       'first_name', 'eq', 'john');
search_dictionary ($table $keyname $c_name $c_value $lha $op $rha)

Searches on single condition in single table using dictionary and returns a reference to the list of values in the given key field. Even if the list is empty a reference to the empty list is still returned.

Only supported operations are 'wq' and 'ws'.

setup_dictionary ($$$)

Supposed to set up dictionary tables if required. For MySQL driver it does nothing as all dictionaries are stored in the same table currently and this table is created when initial database layout is created.

store_row ($$$$$$$)

Stores complete row of data into the given table. New name is generated in the given key field if there is no name given.

Example:

$self->_driver->store_row($table,
                          $key_name,$key_value,
                          $conn_name,$conn_value,
                          \%row);

Connector name and connector value are optional if this list is directly underneath of Global.

unique_id ($$$$$)

Looks up row unique ID by given key name and value (required) and connector name and value (optional for top level lists).

update_dictionary ($table $uid $name $value)

Updates dictionary for the given field. Dictionary is supported by two tables Global_Dictionary and Global_Backrefs. The first table is dictionary itself, while the second holds references that allow to delete/modify records in the dictionary quicker.

Here is an example content of Global_Dictionary with two names ('John Silver' and 'John Doe') encoded. It assumes that unique_id's of rows that holds `John Silver' and 'John Doe' in Customers table are 15 and 25 respectfully.

| unique_id | table_name | field_name | strip  |  ids  |
+-----------+------------+------------+--------+-------+
|         1 | Customers  | name       | john   | 15,25 |
|         2 | Customers  | name       | silver | 15    |
|         3 | Customers  | name       | doe    | 25    |

Structure of Global_Backrefs for the same data:

| unique_id | table_name | table_uid | field_name | ids |
+-----------+------------+-----------+------------+-----+
|         1 | Customers  | 15        | name       | 1,2 |
|         2 | Customers  | 25        | name       | 1,3 |
update_field ($$$$) {

Stores new value into single data field. Example:

$self->_driver->update_field($table,$unique_id,$name,$value);
update_key ($$$$) {

Stores new value into key field in the given table. If value for key is not given then it generates new random one just like store_row does.

$self->_driver->update_key($table,$unique_id,$key_name,$key_value);
update_row ($$$$)

Updates multiple fields in the row by unique id and table.

Example:

$self->_driver->update_row($table,$unique_id,\%row);

AUTHORS

Xao, Inc. (c) 2001. This module was developed by Andrew Maltsev <am@xao.com> with help and valuable comments from other team members.

SEE ALSO

Further reading: XAO::FS, XAO::DO::FS::Glue.