Public Member Functions | Protected Member Functions | Protected Attributes

MysqlEngine Class Reference

Inheritance diagram for MysqlEngine:
DbEngine

List of all members.

Public Member Functions

 __construct ($server, $user, $pass)
 __destruct ()
 setPrefix ($pre)
 setDbName ($dbn)
 setStorageEngine ($e)
 setCharacterSet ($cs, $col="%_bin")
 tryConnect ()
 hasTable ($tnm)
 beginTransaction ()
 commitTransaction ()
 rollbackTransaction ()
 sqlBeginTransaction ()
 sqlCommitTransaction ()
 sqlRollbackTransaction ()
 select ($table, $cols, $where="", $orderby="")
 insert ($table, array $values)
 update ($table, array $values, $where)
 deleteRows ($table, $where)
 lastError ()
 escapeString ($s)
 escapeBlob ($s)
 escapeBool ($b)

Protected Member Functions

 lockDB ($wl)
 unlockDB ()
 createTable ($tn, $t)
 sqlCreateTable ($tn, $t)
 createTableExtras ($tablename, $table)
 tableName ($tn)
 dataType ($type)
 columnFlag ($flag, $col, $table)

Protected Attributes

 $prefix = ""

Detailed Description

MySQL adaptation of DB-Engine


Constructor & Destructor Documentation

MysqlEngine::__construct ( server,
user,
pass 
)

initialize driver

MysqlEngine::__destruct (  ) 

make sure it shuts down


Member Function Documentation

MysqlEngine::beginTransaction (  ) 

begins a transaction; must be implemented by driver; use sqlBeginTransaction to create the SQL statement!

Reimplemented from DbEngine.

MysqlEngine::columnFlag ( flag,
col,
table 
) [protected]

returns the correct name/coding of a flag: primarykey, notnull, unique (implies notnull), foreignkey:$table:$col, defaultint:$val, defaultstr:$val, index

Reimplemented from DbEngine.

MysqlEngine::commitTransaction (  ) 

ends a transaction successfully; must be implemented by driver; returns true on success; use sqlCommitTransaction to create the SQL statement!

Reimplemented from DbEngine.

MysqlEngine::createTable ( tablename,
table 
) [protected]

creates a table; the argument is an array of the form "col-name" => array("col-type", "flags"...); use sqlCreateTable() etc. to create the actual statement

Reimplemented from DbEngine.

MysqlEngine::createTableExtras ( tablename,
table 
) [protected]

This function can be used to amend the column definitions of a table; if overwritten it must return a string; overwrite this to implement DB specific syntax

Reimplemented from DbEngine.

MysqlEngine::dataType ( type  )  [protected]

returns the correct type name for the required abstract data type; types that must be understood are: int32 (INTEGER), int64 (LONG INTEGER), seq32 (auto-incrementing int), seq64, bool (boolean), string:$length (text up to 255 chars, length is optional, default is 255; VARCHAR($length)), text (unlimited text)

Reimplemented from DbEngine.

MysqlEngine::deleteRows ( table,
where 
)

delete database values; returns the amount of rows deleted or false if an error occurred; use sqlDelete to create the SQL statement!

Reimplemented from DbEngine.

MysqlEngine::escapeBlob ( s  ) 

escapes blobs; it uses mysqli_escape_string and encloses the value in '' - blobs are binary strings in MySQL

Reimplemented from DbEngine.

MysqlEngine::escapeBool ( b  ) 

escapes booleans, overwrites the orignal to use "0" and "1" instead of "FALSE" and "TRUE"

Reimplemented from DbEngine.

MysqlEngine::escapeString ( s  ) 

escapes strings; it uses mysqli_escape_string and encloses the value in ''

Reimplemented from DbEngine.

MysqlEngine::hasTable ( tablename  ) 

returns whether the table exists; must be implemented by driver

Reimplemented from DbEngine.

MysqlEngine::insert ( table,
array $  values 
)

insert values into a table; returns false on failure, the new primary key if a sequence was set, true otherwise; use sqlInsert to create the SQL statement!

Reimplemented from DbEngine.

MysqlEngine::lastError (  ) 

returns the error string of the last operation

Reimplemented from DbEngine.

MysqlEngine::lockDB ( writelock  )  [protected]

locks the database - only used by the backup functions; if necessary should also start a transaction; default just starts a transaction

Reimplemented from DbEngine.

MysqlEngine::rollbackTransaction (  ) 

ends a transaction with a rollback; must be implemented by driver; returns true on success; use sqlRollbackTransaction to create the SQL statement!

Reimplemented from DbEngine.

MysqlEngine::select ( table,
cols,
where = "",
orderby = "" 
)

gets some data from the database; $table is the name of the table, $cols is the list of columns to return or "*" for all, $where is the where clause of the SQL-statement, $orderby may contain additional ORDER BY or GROUP BY clauses; returns array of rows, which are in *_fetch_array format; returns false on error; use sqlSelect to create the SQL statement!; make sure that NULL values are returned as PHP value null (most DB drivers already do this)

Reimplemented from DbEngine.

MysqlEngine::setCharacterSet ( cs,
col = "%_bin" 
)

set the default charset and collation for tables and connections

Parameters:
cs the character set - like 'latin1' or 'utf8', this must be a charset supported by MySQL, the default is 'utf8'
col the collation to be used, the default is to use the corresponding binary collation (if you specify an empty string the default of MySQL will be used, which is a case independent comparison!)
MysqlEngine::setDbName ( dbn  ) 

set the name of the database to be used

MysqlEngine::setPrefix ( pre  ) 

set a table-name prefix for the database

MysqlEngine::setStorageEngine ( e  ) 

set the name of the storage engine to be used on DB creation

MysqlEngine::sqlBeginTransaction (  ) 

returns the SQL92 statement for beginning a transaction; overwrite this to implement DB specific syntax

Reimplemented from DbEngine.

MysqlEngine::sqlCommitTransaction (  ) 

returns the SQL92 statement for committing a transaction; overwrite this to implement DB specific syntax

Reimplemented from DbEngine.

MysqlEngine::sqlCreateTable ( tablename,
table 
) [protected]

creates a SQL92 statement for creating a table; overwrite this to implement DB specific syntax

Reimplemented from DbEngine.

MysqlEngine::sqlRollbackTransaction (  ) 

returns the SQL92 statement for rolling a transaction back; overwrite this to implement DB specific syntax

Reimplemented from DbEngine.

MysqlEngine::tableName ( tname  )  [protected]

transform an internally used table name to the actual table name in the DB; the default implementation returns exactly what it gets

Reimplemented from DbEngine.

MysqlEngine::tryConnect (  ) 

connect to the database, must be overwritten by DB driver

Reimplemented from DbEngine.

MysqlEngine::unlockDB (  )  [protected]

unlocks the database - only used by the backup functions; if necessary should also commit a transaction; default just commits

Reimplemented from DbEngine.

MysqlEngine::update ( table,
array $  values,
where 
)

update database values; returns how many rows have been changed or false for failure; use sqlUpdate to create the SQL statement!

Reimplemented from DbEngine.


Member Data Documentation

MysqlEngine::$prefix = "" [protected]

prefix for table names


The documentation for this class was generated from the following file: