XOOPS  2.6.0
Xmf\Database\Tables Class Reference

Public Member Functions

 __construct ()
 
 addColumn ($table, $column, $attributes, $position=null)
 
 addPrimaryKey ($table, $column)
 
 addTable ($table)
 
 alterColumn ($table, $column, $attributes, $newName= '', $position=null)
 
 copyTable ($table, $newTable, $withData=false)
 
 createIndex ($name, $table, $column, $unique=false)
 
 delete ($table, $criteria)
 
 dropColumn ($table, $column)
 
 dropIndex ($name, $table)
 
 dropIndexes ($table)
 
 dropPrimaryKey ($table)
 
 dropTable ($table)
 
 dumpQueue ()
 
 dumpTables ()
 
 getLastErrNo ()
 
 getLastError ()
 
 insert ($table, $columns)
 
 name ($table)
 
 queueExecute ($force=false)
 
 queueReset ()
 
 renameTable ($table, $newName)
 
 renderTableCreate ($table, $prefixed=false)
 
 setTableOptions ($table, $options)
 
 truncate ($table)
 
 update ($table, $columns, $criteria)
 
 useTable ($table)
 

Public Attributes

const POSITION_FIRST = 1
 

Protected Attributes

 $lastErrNo
 
 $lastError
 

Private Member Functions

execSql ($sql, $force=false)
 
 expandQueue ()
 
 fetch (&$result)
 
 getTable ($table)
 

Private Attributes

 $db
 
 $queue
 
 $tables
 

Detailed Description

Definition at line 36 of file Tables.php.

Constructor & Destructor Documentation

Xmf\Database\Tables::__construct ( )

Constructor

Definition at line 72 of file Tables.php.

References $xoopsDB, Xmf\Language\load(), and Xmf\Database\Tables\queueReset().

Here is the call graph for this function:

Member Function Documentation

Xmf\Database\Tables::addColumn (   $table,
  $column,
  $attributes,
  $position = null 
)

Add new column for table to the work queue

Parameters
string$tabletable to contain the column
string$columnname of column to add
array$attributescolumn_definition
mixed$positionFIRST, string of column name to add new column after, or null for natural append
Returns
bool true if no errors, false if errors encountered

Definition at line 105 of file Tables.php.

References $i, _DB_XMF_TABLE_IS_NOT_DEFINED, and Xmf\Database\Tables\POSITION_FIRST.

Xmf\Database\Tables::addPrimaryKey (   $table,
  $column 
)

Add new primary key definition for table to work queue

Parameters
string$tabletable
string$columncolumn or comma separated list of columns to use as primary key
Returns
bool true if no errors, false if errors encountered

Definition at line 182 of file Tables.php.

References _DB_XMF_TABLE_IS_NOT_DEFINED.

Xmf\Database\Tables::addTable (   $table)

Load table schema from database, or starts new empty schema if table doesn't exist

Parameters
string$tabletable
Returns
bool true if no errors, false if errors encountered

Definition at line 205 of file Tables.php.

References Xmf\Database\Tables\getTable().

Here is the call graph for this function:

Xmf\Database\Tables::alterColumn (   $table,
  $column,
  $attributes,
  $newName = '',
  $position = null 
)

Add alter column operation to the work queue

Parameters
string$tabletable containing the column
string$columncolumn to alter
array$attributesnew column_definition
string$newNamenew name for column, blank to keep same
mixed$positionFIRST, string of column name to add new column after, or null for no change
Returns
bool true if no errors, false if errors encountered

Definition at line 266 of file Tables.php.

References _DB_XMF_TABLE_IS_NOT_DEFINED, and Xmf\Database\Tables\POSITION_FIRST.

Xmf\Database\Tables::copyTable (   $table,
  $newTable,
  $withData = false 
)

Loads table schema from database, and adds newTable with that schema to the queue

Parameters
string$tableexisting table
string$newTablenew table
bool$withDatatrue to copy data, false for schema only
Returns
bool true if no errors, false if errors encountered

Definition at line 324 of file Tables.php.

References Xmf\Database\Tables\getTable(), and Xmf\Database\Tables\name().

Here is the call graph for this function:

Xmf\Database\Tables::createIndex (   $name,
  $table,
  $column,
  $unique = false 
)

Add new index definition for index to work queue

Parameters
string$namename of index to add
string$tabletable indexed
string$columncolumn or comma separated list of columns to use as the key
bool$uniquetrue if index is to be unique
Returns
bool true if no errors, false if errors encountered

Definition at line 363 of file Tables.php.

References _DB_XMF_TABLE_IS_NOT_DEFINED.

Xmf\Database\Tables::delete (   $table,
  $criteria 
)

Create DELETE statement and add to queue

Parameters
string$tabletable
mixed$criteriastring where clause or object criteria
Returns
bool true if no errors, false if errors encountered

Definition at line 610 of file Tables.php.

References $criteria, and _DB_XMF_TABLE_IS_NOT_DEFINED.

Xmf\Database\Tables::dropColumn (   $table,
  $column 
)

Add drop column operation to the work queue

Parameters
string$tabletable containing the column
string$columncolumn to drop
Returns
bool true if no errors, false if errors encountered

Definition at line 388 of file Tables.php.

References _DB_XMF_TABLE_IS_NOT_DEFINED.

Xmf\Database\Tables::dropIndex (   $name,
  $table 
)

Add drop index operation to the work queue

Parameters
string$namename of index to drop
string$tabletable indexed
Returns
bool true if no errors, false if errors encountered

Definition at line 413 of file Tables.php.

References _DB_XMF_TABLE_IS_NOT_DEFINED.

Xmf\Database\Tables::dropIndexes (   $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.

Parameters
string$tabletable indexed
Returns
bool true if no errors, false if errors encountered

Definition at line 436 of file Tables.php.

References _DB_XMF_TABLE_IS_NOT_DEFINED.

Xmf\Database\Tables::dropPrimaryKey (   $table)

Add drop of PRIMARY key for a table to the work queue

Parameters
string$tabletable
Returns
bool true if no errors, false if errors encountered

Definition at line 475 of file Tables.php.

References _DB_XMF_TABLE_IS_NOT_DEFINED.

Xmf\Database\Tables::dropTable (   $table)

Add drop of table to the work queue

Parameters
string$tabletable
Returns
bool true if no errors, false if errors encountered

Definition at line 497 of file Tables.php.

Xmf\Database\Tables::dumpQueue ( )

dumpQueue - development function to dump the work queue

Returns
array work queue

Definition at line 959 of file Tables.php.

Xmf\Database\Tables::dumpTables ( )

dumpTables - development function to dump raw tables array

Returns
Tables tables

Definition at line 949 of file Tables.php.

& Xmf\Database\Tables::execSql (   $sql,
  $force = false 
)
private

execute an SQL statement

Parameters
string$sqlSQL statement to execute
bool$forcetrue to use queryF
Returns
mixed result resouce if no error, true if no error but no result false if error encountered. Any error message is in $this->lastError;

Definition at line 778 of file Tables.php.

References $result, and $sql.

Referenced by Xmf\Database\Tables\queueExecute().

Here is the caller graph for this function:

Xmf\Database\Tables::expandQueue ( )
private

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.

Returns
void

Definition at line 913 of file Tables.php.

Referenced by Xmf\Database\Tables\queueExecute().

Here is the caller graph for this function:

Xmf\Database\Tables::fetch ( $result)
private

fetch the next row of a result set

Parameters
resource&$resultas returned by query
Returns
bool true if no errors and table is loaded, false if error presented. Error message in $this->lastError;

Definition at line 803 of file Tables.php.

References $result.

Xmf\Database\Tables::getLastErrNo ( )

Return code from last error encountered

Returns
int last error number

Definition at line 939 of file Tables.php.

Xmf\Database\Tables::getLastError ( )

Return message from last error encountered

Returns
string last error message

Definition at line 929 of file Tables.php.

Xmf\Database\Tables::getTable (   $table)
private

get table definition from INFORMATION_SCHEMA

Parameters
string$tabletable
Returns
bool true if no errors and table is loaded, false if error presented. Error message in $this->lastError;

Definition at line 816 of file Tables.php.

References $sql, XoopsBaseConfig\get(), and Xmf\Database\Tables\name().

Referenced by Xmf\Database\Tables\addTable(), Xmf\Database\Tables\copyTable(), and Xmf\Database\Tables\useTable().

Here is the call graph for this function:

Here is the caller graph for this function:

Xmf\Database\Tables::insert (   $table,
  $columns 
)

Create an INSERT SQL statement and add to queue.

Parameters
string$tabletable
array$columnsarray of 'column'=>'value' entries
Returns
boolean|null true if no errors, false if errors encountered

Definition at line 638 of file Tables.php.

References $sql, and _DB_XMF_TABLE_IS_NOT_DEFINED.

Xmf\Database\Tables::name (   $table)

Return a table name, prefixed with site table prefix

Parameters
string$tabletable name to contain prefix
Returns
string table name with prefix

Definition at line 89 of file Tables.php.

Referenced by Xmf\Database\Tables\copyTable(), Xmf\Database\Tables\getTable(), and Xmf\Database\Tables\renameTable().

Here is the caller graph for this function:

Xmf\Database\Tables::queueExecute (   $force = false)

Execute the work queue

Parameters
bool$forcetrue to force updates even if this is a 'GET' request
Returns
bool true if no errors, false if errors encountered

Definition at line 580 of file Tables.php.

References $result, Xmf\Database\Tables\execSql(), Xmf\Database\Tables\expandQueue(), and Xmf\Database\Tables\renderTableCreate().

Here is the call graph for this function:

Xmf\Database\Tables::queueReset ( )

Clear the work queue

Returns
void

Definition at line 567 of file Tables.php.

Referenced by Xmf\Database\Tables\__construct().

Here is the caller graph for this function:

Xmf\Database\Tables::renameTable (   $table,
  $newName 
)

Add rename table operation to the work queue

Parameters
string$tabletable
string$newNamenew table name
Returns
bool true if no errors, false if errors encountered

Definition at line 517 of file Tables.php.

References _DB_XMF_TABLE_IS_NOT_DEFINED, and Xmf\Database\Tables\name().

Here is the call graph for this function:

Xmf\Database\Tables::renderTableCreate (   $table,
  $prefixed = false 
)

return SQL to create the table

Parameters
string$tabletable
bool$prefixedtrue to return with table name prefixed
Returns
string|null string SQL to create table, or null if errors encountered

Definition at line 734 of file Tables.php.

References $sql, and _DB_XMF_TABLE_IS_NOT_DEFINED.

Referenced by Xmf\Database\Tables\queueExecute().

Here is the caller graph for this function:

Xmf\Database\Tables::setTableOptions (   $table,
  $options 
)

Add alter table table_options (ENGINE, DEFAULT CHARSET, etc.) to work queue

Parameters
string$tabletable
array$optionstable_options
Returns
bool true if no errors, false if errors encountered

Definition at line 544 of file Tables.php.

References $options, and _DB_XMF_TABLE_IS_NOT_DEFINED.

Xmf\Database\Tables::truncate (   $table)

Add statement to Empty a table to the queue

Parameters
string$tabletable
Returns
bool true if no errors, false if errors encountered

Definition at line 709 of file Tables.php.

References _DB_XMF_TABLE_IS_NOT_DEFINED.

Xmf\Database\Tables::update (   $table,
  $columns,
  $criteria 
)

Creates and executes an UPDATE SQL statement.

Parameters
string$tabletable
array$columnsarray of 'column'=>'value' entries
mixed$criteriastring where clause or object criteria
Returns
boolean|null true if no errors, false if errors encountered

Definition at line 672 of file Tables.php.

References $criteria, $sql, and _DB_XMF_TABLE_IS_NOT_DEFINED.

Xmf\Database\Tables::useTable (   $table)

AddTable only if it exists

Parameters
string$tabletable
Returns
bool true if table exists, false otherwise

Definition at line 240 of file Tables.php.

References Xmf\Database\Tables\getTable().

Here is the call graph for this function:

Member Data Documentation

Xmf\Database\Tables::$db
private

Definition at line 46 of file Tables.php.

Xmf\Database\Tables::$lastErrNo
protected

Definition at line 66 of file Tables.php.

Xmf\Database\Tables::$lastError
protected

Definition at line 61 of file Tables.php.

Xmf\Database\Tables::$queue
private

Definition at line 56 of file Tables.php.

Xmf\Database\Tables::$tables
private

Definition at line 51 of file Tables.php.

const Xmf\Database\Tables::POSITION_FIRST = 1

for add/alter column position

Definition at line 41 of file Tables.php.

Referenced by Xmf\Database\Tables\addColumn(), and Xmf\Database\Tables\alterColumn().


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