MagicSmoke  $VERSION$
MysqlEngine Class Reference

MySQL adaptation of DB-Engine. More...

Inheritance diagram for MysqlEngine:
DbEngine

Public Member Functions

 __construct ($server, $user, $pass)
 initialize driver More...
 
 __destruct ()
 make sure it shuts down More...
 
 beginTransaction ()
 
 commitTransaction ()
 
 dbName ()
 return the name of the database More...
 
 deleteRows ($table, $where)
 
 escapeBlob ($s)
 escapes blobs; it uses mysqli_escape_string and encloses the value in '' - blobs are binary strings in MySQL More...
 
 escapeBool ($b)
 escapes booleans, overwrites the orignal to use "0" and "1" instead of "FALSE" and "TRUE" More...
 
 escapeString ($s)
 escapes strings; it uses mysqli_escape_string and encloses the value in '' More...
 
 hasTable ($tnm)
 
 insert ($table, array $values)
 
 isConnected ()
 check whether the DB object is connected to an actual database More...
 
 lastError ()
 
 rollbackTransaction ()
 
 select ($table, $cols, $where="", $orderby="")
 
 setCharacterSet ($cs, $col="%_bin")
 set the default charset and collation for tables and connections More...
 
 setDbName ($dbn)
 set the name of the database to be used More...
 
 setPrefix ($pre)
 set a table-name prefix for the database More...
 
 setStorageEngine ($e)
 set the name of the storage engine to be used on DB creation More...
 
 sqlBeginTransaction ()
 
 sqlCommitTransaction ()
 
 sqlRollbackTransaction ()
 
 tableName ($tn)
 
 tryConnect ()
 
 update ($table, array $values, $where)
 
- Public Member Functions inherited from DbEngine
 beginTransaction ()
 begins a transaction; must be implemented by driver; use sqlBeginTransaction to create the SQL statement! More...
 
 canAdministrate ()
 returns whether a passcode is known and admin.php may be used More...
 
 canUseDb ($checkVersion=true)
 tries to find out whether the connected DB version is usable More...
 
 checkAdmin ()
 check admin credentials More...
 
 commitTransaction ()
 ends a transaction successfully; must be implemented by driver; returns true on success; use sqlCommitTransaction to create the SQL statement! More...
 
 createDb ()
 creates the database, used by admin.php only!! More...
 
 dbName ()
 returns the name of the database the instance is connected to More...
 
 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! More...
 
 dumpBackup ()
 dump a backup (returned as string) More...
 
 escapeBlob ($s)
 escapes blobs; the default uses addslashes and encloses the value in ''; it is recommended to overwrite this with the proper escaping procedure for the target DB More...
 
 escapeBool ($s)
 escapes a boolean value; the default translates 0, '0', 'f', 'false', 'n', 'no', false to FALSE and numerics !=0, 't', 'true', 'y', 'yes', true to TRUE; any other value (incl. More...
 
 escapeColumn ($table, $col, $val)
 generic escape routine: queries the schema for the correct escape mechanism and then returns the appropriately escaped value More...
 
 escapeInt ($i)
 escapes integers; the default implementation just makes sure it is an int (false and null are translated to NULL) More...
 
 escapeIntList (array $il)
 escapes a list of integers; uses escapeInt for each element; automatically adds parentheses More...
 
 escapeListColumn (array $il, $table, $col)
 escapes a list of values for a specific column; uses escapeInt for each element; automatically adds parentheses More...
 
 escapeString ($s)
 escapes strings; the default uses addslashes and encloses the value in ''; it is recommended to overwrite this with the proper escaping procedure for the target DB (false and null are translated to NULL) More...
 
 escapeStringList (array $il)
 escapes a list of strings; uses escapeInt for each element; automatically adds parentheses More...
 
 exploreBackup ()
 explore the backup settings and database and return an index to the current data as structured text; each line has the following format: S T tablename [min max [groupSize]] V base64value E More...
 
 getConfig ($key)
 returns a configuration setting More...
 
 hasTable ($tablename)
 returns whether the table exists; must be implemented by driver More...
 
 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! More...
 
 isConnected ()
 check whether the DB object is connected to an actual database More...
 
 isNull ($val)
 returns whether the result value is NULL; the default interprets only the special value null as NULL More...
 
 lastError ()
 returns the error string of the last operation More...
 
 needVersion ()
 returns the version of the DB layout that is required by this version of Magic Smoke More...
 
 restoreData ($file, $overwrite)
 called from admin.php: restore a backup More...
 
 rollbackTransaction ()
 ends a transaction with a rollback; must be implemented by driver; returns true on success; use sqlRollbackTransaction to create the SQL statement! More...
 
 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) More...
 
 setAdminPassCode ($u, $p)
 set the admin passcode; used by the config.php file if admin access is allowed More...
 
 setConfig ($key, $val)
 sets a config setting More...
 
 setTransactionUpdating ($tm)
 set the transaction mode: true if it is an updating transaction More...
 
 showCreateDb ()
 shows how the database would be created, used by admin.php only!! More...
 
 sqlBeginTransaction ()
 returns the SQL92 statement for beginning a transaction; overwrite this to implement DB specific syntax More...
 
 sqlCommitTransaction ()
 returns the SQL92 statement for committing a transaction; overwrite this to implement DB specific syntax More...
 
 sqlRollbackTransaction ()
 returns the SQL92 statement for rolling a transaction back; overwrite this to implement DB specific syntax More...
 
 sqlSelect ($table, $cols, $where, $orderby)
 creates a SQL92 statement for selects; overwrite this to implement DB specific syntax; the concrete DB implementation should append "for update" to the select statement if $this->transmode is true and the DB supports it More...
 
 syncSequence ($table)
 synchronize the sequence of one database table; overwrite to actually do something More...
 
 syncSequences ()
 synchronize all sequences with current data More...
 
 tableName ($tname)
 transform an internally used table name to the actual table name in the DB; the default implementation returns exactly what it gets More...
 
 transactionIsUpdating ()
 returns whether the DB driver currently believes to be in RW transaction mode More...
 
 tryConnect ()
 connect to the database, must be overwritten by DB driver More...
 
 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! More...
 
 upgradeDb ($doexec=true)
 Upgrades the database, used by admin.php. More...
 

Protected Member Functions

 columnFlag ($flag, $col, $table, $cflags)
 
 createTable ($tn, $t)
 
 createTableExtras ($tablename, $table)
 
 dataType ($type)
 
 lockDB ($wl)
 
 sqlCreateTable ($tn, $t)
 
 unlockDB ()
 
 upgradeTable ($tablename, $doexec)
 
- Protected Member Functions inherited from DbEngine
 columnFlag ($flag, $col, $table, $cflags)
 returns the correct name/coding of a flag: primarykey, notnull, unique (implies notnull), foreignkey:$table:$col, defaultint:$val, defaultstr:$val, index More...
 
 createTable ($tablename, $table)
 creates a table; the argument is an array of the form "col-name" => array("col-type", "flags"...); use sqlCreateTable() etc. More...
 
 createTableExtras ($tablename, $table)
 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. More...
 
 dataType ($type)
 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) More...
 
 lockDB ($writelock)
 locks the database - only used by the backup functions; if necessary should also start a transaction; default just starts a transaction More...
 
 sqlCreateColumn ($tablename, $columnname, $columndef, $flags=self::COLUMN_CREATE_ALL)
 creates SQL92 part of a statement for creating a single column More...
 
 sqlCreateTable ($tablename, $table)
 creates a SQL92 statement for creating a table; overwrite this to implement DB specific syntax More...
 
 sqlCreateTablePrimaryKey (array $cols)
 creates primary key statement for sqlCreateTable; overwrite this to implement DB specific syntax More...
 
 sqlCreateTableUniqueConstraint (array $constraints)
 creates the complex unique constraints; overwrite this to implement DB specific syntax More...
 
 sqlDelete ($table, $where)
 creates a SQL92 statement for deletes; overwrite this to implement DB specific syntax More...
 
 sqlInsert ($table, array $values)
 creates a SQL92 statement for inserts; overwrite this to implement DB specific syntax More...
 
 sqlUpdate ($table, array $values, $where)
 creates a SQL92 statement for updates; overwrite this to implement DB specific syntax More...
 
 unlockDB ()
 unlocks the database - only used by the backup functions; if necessary should also commit a transaction; default just commits More...
 
 upgradeTable ($tablename, $doexec)
 helper for upgradeDb -> upgrades a single table More...
 

Protected Attributes

 $prefix =""
 prefix for table names More...
 
- Protected Attributes inherited from DbEngine
 $transmode =false
 transaction RO/RW mode: false=assume readonly, true=assume inserts/updates More...
 

Additional Inherited Members

- Public Attributes inherited from DbEngine
const COLUMN_CREATE_ALL = 0xffff
 
const COLUMN_CREATE_CONSTRAINT = 64
 
const COLUMN_CREATE_DEFAULT = 16
 
const COLUMN_CREATE_FKEY = 8
 
const COLUMN_CREATE_INDEX = 32
 
const COLUMN_CREATE_KEY = 12
 
const COLUMN_CREATE_NULL = 2
 
const COLUMN_CREATE_PKEY = 4
 
const COLUMN_CREATE_TYPE = 1
 

Detailed Description

MySQL adaptation of DB-Engine.

Constructor & Destructor Documentation

MysqlEngine::__construct (   $server,
  $user,
  $pass 
)

initialize driver

MysqlEngine::__destruct ( )

make sure it shuts down

References rollbackTransaction().

Member Function Documentation

MysqlEngine::beginTransaction ( )
MysqlEngine::columnFlag (   $flag,
  $col,
  $table,
  $cflags 
)
protected

References $col, and tableName().

MysqlEngine::commitTransaction ( )
MysqlEngine::createTable (   $tn,
  $t 
)
protected
MysqlEngine::createTableExtras (   $tablename,
  $table 
)
protected
MysqlEngine::dataType (   $type)
protected
MysqlEngine::dbName ( )

return the name of the database

Referenced by hasTable(), and upgradeTable().

MysqlEngine::deleteRows (   $table,
  $where 
)
MysqlEngine::escapeBlob (   $s)

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

MysqlEngine::escapeBool (   $b)

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

References DbEngine\escapeBool().

MysqlEngine::escapeString (   $s)

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

Referenced by hasTable(), tryConnect(), and upgradeTable().

MysqlEngine::hasTable (   $tnm)
MysqlEngine::insert (   $table,
array  $values 
)
MysqlEngine::isConnected ( )

check whether the DB object is connected to an actual database

MysqlEngine::lastError ( )

Referenced by upgradeTable().

MysqlEngine::lockDB (   $wl)
protected
MysqlEngine::rollbackTransaction ( )
MysqlEngine::select (   $table,
  $cols,
  $where = "",
  $orderby = "" 
)
MysqlEngine::setCharacterSet (   $cs,
  $col = "%_bin" 
)

set the default charset and collation for tables and connections

Parameters
csthe character set - like 'latin1' or 'utf8', this must be a charset supported by MySQL, the default is 'utf8'
colthe 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!)

References $col, and $cs.

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 ( )

Referenced by beginTransaction().

MysqlEngine::sqlCommitTransaction ( )

Referenced by commitTransaction().

MysqlEngine::sqlCreateTable (   $tn,
  $t 
)
protected

Referenced by createTable().

MysqlEngine::sqlRollbackTransaction ( )

Referenced by rollbackTransaction().

MysqlEngine::tableName (   $tn)
MysqlEngine::tryConnect ( )

References $col, $cs, $q, and escapeString().

MysqlEngine::unlockDB ( )
protected
MysqlEngine::update (   $table,
array  $values,
  $where 
)
MysqlEngine::upgradeTable (   $tablename,
  $doexec 
)
protected

Member Data Documentation

MysqlEngine::$prefix =""
protected

prefix for table names


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