API - XOOPS 2.5.11 Beta 2
By monxoops.fr
Tables Class Reference

Public Member Functions

 __construct ()
 
 addColumn ($table, $column, $attributes)
 
 addPrimaryKey ($table, $column)
 
 addIndex ($name, $table, $column, $unique=false)
 
 addTable ($table)
 
 useTable ($table)
 
 getColumnAttributes ($table, $column)
 
 getTableIndexes ($table)
 
 alterColumn ($table, $column, $attributes, $newName='')
 
 copyTable ($table, $newTable, $withData=false)
 
 dropColumn ($table, $column)
 
 dropIndex ($name, $table)
 
 dropIndexes ($table)
 
 dropPrimaryKey ($table)
 
 dropTable ($table)
 
 renameTable ($table, $newName)
 
 setTableOptions ($table, $options)
 
 resetQueue ()
 
 executeQueue ($force=false)
 
 delete ($table, $criteria)
 
 insert ($table, $columns, $quoteValue=true)
 
 update ($table, $columns, $criteria, $quoteValue=true)
 
 truncate ($table)
 
 getLastError ()
 
 getLastErrNo ()
 
 dumpTables ()
 
 dumpQueue ()
 
 addToQueue ($sql)
 

Protected Member Functions

 name ($table)
 
 quoteIndexColumnName ($columnName)
 
 renderTableCreate ($table, $prefixed=false)
 
 execSql ($sql, $force=false)
 
 fetch ($result)
 
 quoteDefaultClause ($default)
 
 getTable ($table)
 
 expandQueue ()
 
 tableNotEstablished ()
 

Protected Attributes

 $db
 
 $databaseName
 
 $tables
 
 $queue
 
 $lastError
 
 $lastErrNo
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Constructor

Here is the call graph for this function:

Member Function Documentation

◆ addColumn()

addColumn (   $table,
  $column,
  $attributes 
)

Add new column for table to the work queue

Parameters
string$tabletable to contain the column
string$columnname of column to add
string$attributescolumn_definition
Returns
bool true if no errors, false if errors encountered
Here is the call graph for this function:

◆ addIndex()

addIndex (   $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 a 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
Here is the call graph for this function:

◆ addPrimaryKey()

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
Here is the call graph for this function:

◆ addTable()

addTable (   $table)

Load table schema from database, or starts new empty schema if table does not exist

Parameters
string$tabletable
Returns
bool true if no errors, false if errors encountered
Here is the call graph for this function:

◆ addToQueue()

addToQueue (   $sql)

addToQueue - utility function to add a statement to the work queue

Parameters
string$sqlan SQL/DDL statement to add
Returns
void

◆ alterColumn()

alterColumn (   $table,
  $column,
  $attributes,
  $newName = '' 
)

Add alter column operation to the work queue

Parameters
string$tabletable containing the column
string$columncolumn to alter
string$attributesnew column_definition
string$newNamenew name for column, blank to keep same
Returns
bool true if no errors, false if errors encountered
Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyTable()

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
Here is the call graph for this function:

◆ delete()

delete (   $table,
  $criteria 
)

Create a DELETE statement and add it to the work queue

Parameters
string$tabletable
string | CriteriaElement$criteriastring where clause or object criteria
Returns
bool true if no errors, false if errors encountered
Here is the call graph for this function:

◆ dropColumn()

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
Here is the call graph for this function:

◆ dropIndex()

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
Here is the call graph for this function:

◆ dropIndexes()

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
Here is the call graph for this function:

◆ dropPrimaryKey()

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
Here is the call graph for this function:

◆ dropTable()

dropTable (   $table)

Add drop of table to the work queue

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

◆ dumpQueue()

dumpQueue ( )

dumpQueue - utility function to dump the work queue

Returns
array work queue

◆ dumpTables()

dumpTables ( )

dumpTables - utility function to dump raw tables array

Returns
array tables

◆ execSql()

execSql (   $sql,
  $force = false 
)
protected

execute an SQL statement

Parameters
string$sqlSQL statement to execute
bool$forcetrue 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;
Here is the caller graph for this function:

◆ executeQueue()

executeQueue (   $force = false)

Executes 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
Here is the call graph for this function:

◆ expandQueue()

expandQueue ( )
protected

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
Here is the caller graph for this function:

◆ fetch()

fetch (   $result)
protected

fetch the next row of a result set

Parameters
resource$resultas returned by query
Returns
mixed false on error

◆ getColumnAttributes()

getColumnAttributes (   $table,
  $column 
)

Get column attributes

Parameters
string$tabletable containing the column
string$columncolumn to alter
Returns
string|false attribute string, or false if error encountered
Here is the caller graph for this function:

◆ getLastErrNo()

getLastErrNo ( )

Return code from last error encountered

Returns
int last error number

◆ getLastError()

getLastError ( )

Return message from last error encountered

Returns
string last error message

◆ getTable()

getTable (   $table)
protected

get table definition from INFORMATION_SCHEMA

Parameters
string$tabletable
Returns
array|bool table definition array if table exists, true if table not defined, or false on error. Error message in $this->lastError;
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTableIndexes()

getTableIndexes (   $table)

Get indexes for a table

Parameters
string$tableget indexes for this named table
Returns
array|false array of indexes, or false if error encountered

◆ insert()

insert (   $table,
  $columns,
  $quoteValue = true 
)

Create an INSERT SQL statement and add it to the work queue.

Parameters
string$tabletable
array$columnsarray of 'column'=>'value' entries
boolean$quoteValuetrue to quote values, false if caller handles quoting
Returns
boolean true if no errors, false if errors encountered
Here is the call graph for this function:

◆ name()

name (   $table)
protected

Return a table name, prefixed with site table prefix

Parameters
string$tabletable name to contain prefix
Returns
string table name with prefix
Here is the caller graph for this function:

◆ quoteDefaultClause()

quoteDefaultClause (   $default)
protected

create default value clause for DDL

Parameters
string | null$defaultthe default value to be quoted
Returns
string the correctly quoted default value

◆ quoteIndexColumnName()

quoteIndexColumnName (   $columnName)
protected

Backtick quote the column names used in index creation.

Handles prefix indexed columns specified as name(length) - i.e. name(20).

Parameters
string$columnNamecolumn name to quote with optional prefix length
Returns
string
Here is the caller graph for this function:

◆ renameTable()

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
Here is the call graph for this function:

◆ renderTableCreate()

renderTableCreate (   $table,
  $prefixed = false 
)
protected

return SQL to create the table

This method does NOT modify the work queue

Parameters
string$tabletable
bool$prefixedtrue to return with table name prefixed
Returns
string|false string SQL to create table, or false if errors encountered
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetQueue()

resetQueue ( )

Clear the work queue

Returns
void
Here is the caller graph for this function:

◆ setTableOptions()

setTableOptions (   $table,
  $options 
)

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

Parameters
string$tabletable
string$optionstable_options
Returns
bool true if no errors, false if errors encountered
Here is the call graph for this function:

◆ tableNotEstablished()

tableNotEstablished ( )
protected

Set lastError as table not established

Returns
false
Here is the caller graph for this function:

◆ truncate()

truncate (   $table)

Add statement to remove all rows from a table to the work queue

Parameters
string$tabletable
Returns
bool true if no errors, false if errors encountered
Here is the call graph for this function:

◆ update()

update (   $table,
  $columns,
  $criteria,
  $quoteValue = true 
)

Create an UPDATE SQL statement and add it to the work queue

Parameters
string$tabletable
array$columnsarray of 'column'=>'value' entries
string | CriteriaElement$criteriastring where clause or object criteria
boolean$quoteValuetrue to quote values, false if caller handles quoting
Returns
boolean true if no errors, false if errors encountered
Here is the call graph for this function:

◆ useTable()

useTable (   $table)

AddTable only if it exists

Parameters
string$tabletable
Returns
bool true if table exists, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ $databaseName

$databaseName
protected

◆ $db

$db
protected

◆ $lastErrNo

$lastErrNo
protected

◆ $lastError

$lastError
protected

◆ $queue

$queue
protected

◆ $tables

$tables
protected

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