Methods summary
public
|
|
protected
string
|
#
name( string $table )
Return a table name, prefixed with site table prefix
Return a table name, prefixed with site table prefix
Parameters
- $table
- table name to contain prefix
Returns
string table name with prefix
|
public
boolean
|
#
addColumn( string $table, string $column, string $attributes )
Add new column for table to the work queue
Add new column for table to the work queue
Parameters
- $table
- table to contain the column
- $column
- name of column to add
- $attributes
- column_definition
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
addPrimaryKey( string $table, string $column )
Add new primary key definition for table to work queue
Add new primary key definition for table to work queue
Parameters
- $table
- table
- $column
column or comma separated list of columns
to use as primary key
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
addIndex( string $name, string $table, string $column, boolean $unique = false )
Add new index definition for index to work queue
Add new index definition for index to work queue
Parameters
- $name
- name of index to add
- $table
- table indexed
- $column
column or a comma separated list of columns
to use as the key
- $unique
- true if index is to be unique
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
addTable( string $table )
Load table schema from database, or starts new empty schema if
table does not exist
Load table schema from database, or starts new empty schema if
table does not exist
Parameters
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
useTable( string $table )
AddTable only if it exists
AddTable only if it exists
Parameters
Returns
boolean true if table exists, false otherwise
|
public
string|boolean
|
#
getColumnAttributes( string $table, string $column )
Get column attributes
Parameters
- $table
- table containing the column
- $column
- column to alter
Returns
string|boolean attribute string, or false if error encountered
|
public
array|boolean
|
#
getTableIndexes( string $table )
Get indexes for a table
Parameters
- $table
- get indexes for this named table
Returns
array|boolean array of indexes, or false if error encountered
|
public
boolean
|
#
alterColumn( string $table, string $column, string $attributes, string $newName = '' )
Add alter column operation to the work queue
Add alter column operation to the work queue
Parameters
- $table
- table containing the column
- $column
- column to alter
- $attributes
- new column_definition
- $newName
- new name for column, blank to keep same
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
copyTable( string $table, string $newTable, boolean $withData = false )
Loads table schema from database, and adds newTable with that
schema to the queue
Loads table schema from database, and adds newTable with that
schema to the queue
Parameters
- $table
- existing table
- $newTable
- new table
- $withData
- true to copy data, false for schema only
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
dropColumn( string $table, string $column )
Add drop column operation to the work queue
Add drop column operation to the work queue
Parameters
- $table
- table containing the column
- $column
- column to drop
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
dropIndex( string $name, string $table )
Add drop index operation to the work queue
Add drop index operation to the work queue
Parameters
- $name
- name of index to drop
- $table
- table indexed
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
dropIndexes( string $table )
Add drop for all (non-PRIMARY) keys for a table to the work
queue. This can be used to clean up indexes with automatic names.
Add drop for all (non-PRIMARY) keys for a table to the work
queue. This can be used to clean up indexes with automatic names.
Parameters
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
dropPrimaryKey( string $table )
Add drop of PRIMARY key for a table to the work queue
Add drop of PRIMARY key for a table to the work queue
Parameters
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
dropTable( string $table )
Add drop of table to the work queue
Add drop of table to the work queue
Parameters
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
renameTable( string $table, string $newName )
Add rename table operation to the work queue
Add rename table operation to the work queue
Parameters
- $table
- table
- $newName
- new table name
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
setTableOptions( string $table, string $options )
Add alter table table_options (ENGINE, DEFAULT CHARSET, etc.)
to work queue
Add alter table table_options (ENGINE, DEFAULT CHARSET, etc.)
to work queue
Parameters
- $table
- table
- $options
- table_options
Returns
boolean true if no errors, false if errors encountered
|
public
|
|
public
boolean
|
#
executeQueue( boolean $force = false )
Executes the work queue
Parameters
- $force
- true to force updates even if this is a 'GET' request
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
delete( string $table, string|CriteriaElement $criteria )
Create a DELETE statement and add it to the work queue
Create a DELETE statement and add it to the work queue
Parameters
- $table
- table
- $criteria
- string where clause or object criteria
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
insert( string $table, array $columns, boolean $quoteValue = true )
Create an INSERT SQL statement and add it to the work queue.
Create an INSERT SQL statement and add it to the work queue.
Parameters
- $table
- table
- $columns
- array of 'column'=>'value' entries
- $quoteValue
- true to quote values, false if caller handles quoting
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
update( string $table, array $columns, string|CriteriaElement $criteria, boolean $quoteValue = true )
Create an UPDATE SQL statement and add it to the work queue
Create an UPDATE SQL statement and add it to the work queue
Parameters
- $table
- table
- $columns
- array of 'column'=>'value' entries
- $criteria
- string where clause or object criteria
- $quoteValue
- true to quote values, false if caller handles quoting
Returns
boolean true if no errors, false if errors encountered
|
public
boolean
|
#
truncate( string $table )
Add statement to remove all rows from a table to the work queue
Add statement to remove all rows from a table to the work queue
Parameters
Returns
boolean true if no errors, false if errors encountered
|
protected
string|false
|
#
renderTableCreate( string $table, boolean $prefixed = false )
return SQL to create the table
return SQL to create the table
This method does NOT modify the work queue
Parameters
- $table
- table
- $prefixed
- true to return with table name prefixed
Returns
string|false string SQL to create table, or false if errors encountered
|
protected
mixed
|
#
execSql( string $sql, boolean $force = false )
execute an SQL statement
Parameters
- $sql
- SQL statement to execute
- $force
- true to use force updates even in safe requests
Returns
mixed result resource if no error,
true if no error but no result
false if error encountered.
Any error message is in $this->lastError;
|
protected
mixed
|
#
fetch( resource $result )
fetch the next row of a result set
fetch the next row of a result set
Parameters
- $result
- as returned by query
Returns
mixed false on error
|
protected
array|boolean
|
#
getTable( string $table )
get table definition from INFORMATION_SCHEMA
get table definition from INFORMATION_SCHEMA
Parameters
Returns
array|boolean table definition array if table exists, true if table not defined, or
false on error. Error message in $this->lastError;
|
protected
|
#
expandQueue( )
During processing, tables to be created are put in the queue as
an array('createtable' => tablename) since the definition is not
complete. This method will expand those references to the full
ddl to create the table.
During processing, tables to be created are put in the queue as
an array('createtable' => tablename) since the definition is not
complete. This method will expand those references to the full
ddl to create the table.
|
public
string
|
#
getLastError( )
Return message from last error encountered
Return message from last error encountered
Returns
string last error message
|
public
integer
|
#
getLastErrNo( )
Return code from last error encountered
Return code from last error encountered
Returns
integer last error number
|
public
array
|
#
dumpTables( )
dumpTables - utility function to dump raw tables array
dumpTables - utility function to dump raw tables array
Returns
array tables
|
public
array
|
#
dumpQueue( )
dumpQueue - utility function to dump the work queue
dumpQueue - utility function to dump the work queue
Returns
array work queue
|
public
|
#
addToQueue( string $sql )
addToQueue - utility function to add a statement to the work queue
addToQueue - utility function to add a statement to the work queue
Parameters
- $sql
- an SQL/DDL statement to add
|
protected
false
|
#
tableNotEstablished( )
Set lastError as table not established
Set lastError as table not established
Returns
false
|