>> YANA 4 PHP Framework >> Docs For Class BufferedDbStream

Class BufferedDbStream

Description

database API

this class is a database abstraction api, that uses pear db

  • access: public

Located in /includes/class_buffereddbstream.php

SerializeableObject
   |
   --BufferedDbStream

Direct descendents

Class Description
FileDb simulate a database

Method Summary

BufferedDbStream BufferedDbStream ([string $filename = ""], [dbServer $server = null])
bool exists ([string $key = ""])
boolean exportStructure (string $filename)
mixed get (mixed $key, [string $search = ""], [string $filter = ""], int $offset, int $limit)
string getTable ()
bool importSQL (string $sqlFile)
boolean insert (string $key, mixed $value)
boolean isEmpty ([string $table = ""])
bool isWriteable ()
boolean join (string $table1, [string $table2 = ""], [string $key1 = ""], [string $key2 = ""])
int length ([string $table = ""], [string $search = ""])
mixed query (string $sqlStmt)
bool remove (string $key, [mixed $in_search = ""], string $search)
string toString ([string $table = ""])
boolean write ()

Methods

Constructor BufferedDbStream
BufferedDbStream BufferedDbStream ([string $filename = ""], [dbServer $server = null])

create a new instance

Each database connection depends on a structure file describing the database. Therefore you have to provide a $filename of such structure file (without path or extension)

These files are to be found in config/db/*.config

Name Type Description
$filename string
$server dbServer
exists
bool exists ([string $key = ""])

Check wether a certain key exists

Returns bool(true), if the adress $key (table, row, column) is defined, and otherwise bool(false). If no argument is provided, the function returns bool(true) if a database connection exists and bool(false) if not.

  • access: public
  • uses: $bufferedDbStream->exists('table.5')
Name Type Description
$key string adress to check
exportStructure
boolean exportStructure (string $filename)

export database structure to a file

Note: if the specified file already exists it will get overwritten.

Structure files need to have the extension '.config' and are to be stored at the directory 'config/db/*.config'.

  • access: public
  • uses: $bufferedDbStream->exportStructure('some_file.config')
Name Type Description
$filename string
get
mixed get (mixed $key, [string $search = ""], [string $filter = ""], int $offset, int $limit)

get values from the database

This returns the values at adress $key starting from $offset and limited to $limit results.

  • access: public
Name Type Description
$key mixed
$search string (optional)
$filter string (optional)
$offset int (optional)
$limit int (optional)
getTable
string getTable ()

get the most recently queried table

  • access: public
importSQL
bool importSQL (string $sqlFile)

import SQL from a file

  • name: buffereddbstream::importsql()
  • access: public
  • uses: $bufferedDbStream->importSQL('some_file.sql')
Name Type Description
$sqlFile string
insert
boolean insert (string $key, mixed $value)

update or insert row

insert $value at position $key

If $key already exists, the previous value gets updated, else the value is created

This function returns bool(true) on success and bool(false) on error. Note, that this function does not auto-commit. This means, changes to the database will NOT be saved unless you call $bufferedDbStream->write().

  • access: public
Name Type Description
$key string
$value mixed
isEmpty
boolean isEmpty ([string $table = ""])

check wether a certain table has no entries

Note: if no table is provided, the most recently used table will be tested instead.

  • access: public
Name Type Description
$table string (optional)
isWriteable
bool isWriteable ()

check wether the current database is readonly

  • access: public
  • uses: $bufferedDbStream->isWriteable()
join
boolean join (string $table1, [string $table2 = ""], [string $key1 = ""], [string $key2 = ""])

join the resultsets for two tables

results in an INNER JOIN $table1, $table2 WHERE $table1.$key1 = $table2.$key2

  • access: public
Name Type Description
$table1 string
$table2 string (optional)
$key1 string (optional)
$key2 string (optional)
length
int length ([string $table = ""], [string $search = ""])

get the number of entries inside a table

  • access: public
Name Type Description
$table string (optional)
$search string (optional)
query
mixed query (string $sqlStmt)

optional API bypass

send a sql-statement directly, bypassing the API

  • access: public
Name Type Description
$sqlStmt string
remove
bool remove (string $key, [mixed $in_search = ""], string $search)

remove one row

For security reasons all delete queries will automatically be limited to 1 row at a time. While this might be seen as a limitation the far more valueable advantage is, no user is able to destroy a whole table - wether by intention or by accident - in only one query. (At least not via this API.)

  • access: public
Name Type Description
$key string
$search string (optional)
toString
string toString ([string $table = ""])

get CSV string from a table

  • access: public
  • uses: $bufferedDbStream->toString('guestbook')
Name Type Description
$table string (optional)

Redefinition of:
SerializeableObject::toString()
«abstract» get a string representation of this object
write
boolean write ()

Commit current transaction

This writes all changes to the database

  • access: public

Inherited Methods

Inherited From SerializeableObject

SerializeableObject::serialize()
SerializeableObject::toString()

Documentation generated on Sat, 16 Sep 2006 17:05:52 +0200 by phpDocumentor 1.3.0RC4

yana author: Thomas MeyerHomepage: www.all-community.de/pub