YaBB3::DataDrivers::Flatfile;


NAME

YaBB3::DataDrivers::Flatfile;


DESCRIPTION

Flatfile Database Driver

Overview

FlatFile-driver (saves data to /PATH_TO_YABB_CGI/[HOST]/[DBNAME]) The host specified in the connect statement defines the first subdirectory (like ``Database'') and is followed by the DB name. The ``host'' directory has to exist.


REQUIREMENTS


USAGE

TO BE FILLED. FOR NOW SEE AT EACH SUB

This is not designed to be used alone, it is better if used through the DBDriver.pm module

Code Example:

my $DB = YaBB3::DBDriver->new; $DB->db_connect(); my $result=$DB->select('y3_users', {'login', 'password'}, 1, ``uid LIKE '3'''); foreach my $row (@$result){ foreach (keys %$row){ if (defined $$row{$_}){print $$row{$_}} } }


Database File Structure

This is a brief description of current Flatfile Database structure.

The directory ``/PATH_TO_YABB_CGI/[HOST]'' is the database main path. Beneath are the databases with their tables. The files in the database directory forms tables.

Each table consist of 3 files: *.y3tabledesc -> table descriptor file, contains the table structure example: rw 7 offset|length|id|thread_id|parent_id| id,auto_inc,7|thread_id|parent_id|is_thread|is_locked|is_sticky|created|updated|modified|modified_by|smiles|subject|body|replies|views|author|author_ip|author_browser|attachment_id|attach_file|attach_is_image| 0|0|0|0|0|0|0|0|0|0|1|NULL|NULL|0|0|0|NULL|NULL|0|<BL>|0| int(10)_unsigned|int(10)_unsigned|int(10)_unsigned|tinyint(1)_unsigned|tinyint(1)_unsigned|tinyint(1)_unsigned|int(20)|int(20)|int(20)|int(10)|tinyint(1)_unsigned|varchar(35)|text|int(10)_unsigned|int(10)_unsigned|int(10)|varchar(32)|tinytext|int(10)_unsigned|varchar(255)|tinyint(1)_unsigned| PRIMARY KEY (id)|KEY (thread_id)|KEY (parent_id)|

row 1 -> table lock, can be rw (unlocked), lr (locked for read), lw (locked for write) row 2 -> number of rows in the table (used for index consistency checking) row 3 -> index columns definition, offset and length are internal names, they can't be used as KEY's in the tables row 4 -> columns definition, the names of columns (auto increment columns looks like sid in example, the number shows last value) row 5 -> the defaults ('<BL>' means '') row 6 -> variable definitions (currently only the integer variable definitions has meaning in Flatfile DB) row 7 -> key definitions (held for compatibility with MySQL)

*.y3index -> table index file, contains indexed pointers example: 0|191|1|1|1| 192|79|2|1|1| 272|88|3|1|1| 361|80|||| 442|79|5|1|1| 522|79|6|1|1| 602|82|7|1|1|

first two fields (offset and length) are pointers to positions and lengths of each row in the table data the index file is not mandatory, if not exist the driver do the regular handling of data file (reads and writes all of the contents) if the index file is broken or missing, the update or optimize methods rebuilds them the empty values means that the row is deleted

*.y3data -> the table itself example: 1|1|1|0|0|0|1142087237|1142087237|0|0|1|Re: test|[quote date=1142078977 author=``Administrator'' id=1]123456<NR><NL><NR><NL>???::):P:-[:X:-/:-*[/quote]<NR><NL>hjfghjf|0|2|2|NULL|NULL|0|NULL|0| 2|1|1|0|0|0|1143136300|1143136300|0|0|1|Re: test|123|0|0|1|NULL|NULL|0|NULL|0| 3|1|1|0|0|0|1143144211|1143144211|1143151206|1|1|Re: test|123|0|2|1|NULL|NULL|0|NULL|0| ******************************************************************************************* 5|1|1|0|0|0|1143225661|1143225661|0|0|0|Re: test|123|0|0|1|NULL|NULL|0|NULL|0| 6|1|1|0|0|0|1143225727|1143225727|0|0|0|Re: test|123|0|2|1|NULL|NULL|0|NULL|0| 7|1|1|0|0|0|1143226280|1143226280|0|0|0|Re: test|123456|0|2|1|NULL|NULL|0|NULL|0|

the ***ed rows are deleted rows, for speed issues delete method fills deleted row with * and not removes them to keep file length the same. when 'rebuild index' is performed (called by optimize or update methods) deleted rows are removed from table the characters '\n' '\r' and | are escaped like this '<NR>','<NL>','<VL>'

The files can be edited by hand, but only if you know what are you doing. It's for sure that modifying by hand offset and length values in index file leads to broken table. If you need to modify the *data file by hand, the driver will recognize if the index is not valid and skips them untill the update or optimize was performed on table.


AUTHOR

Alexander Boyadjiev

Based on module written by WebRecka- Zach Goldberg Torsten Mrotz

Copyright (C) 2006, YaBB 3 Development Team. All Rights Reserved. You may distribute this module under the terms of YaBB 3.

 YaBB3::DataDrivers::Flatfile;