Property | Type | Description | |
---|---|---|---|
$CaptureOnly | Whether or not to only capture the sql, rather than execute it. When this property is true then a property called CapturedSql will be added to this class which is an array of all the Sql statements. | ||
$Database | The instance of the database singleton. |
Property | Type | Description | |
---|---|---|---|
$_CharacterEncoding | The character encoding to set as default for the table being created. | ||
$_Columns | array | ||
$_DatabasePrefix | string | ||
$_ExistingColumns | The existing columns in the database. | ||
$_TableExists | Whether or not this table exists in the database. | ||
$_TableName | The name of the table to create or modify. | ||
$_TableStorageEngine | The name of the storage engine for this table. |
Method | Description | |
---|---|---|
__construct ( string $Database = null ) | The constructor for this class. Automatically fills $this->ClassName. | |
column ( string $Name, mixed $Type, boolean $NullDefault = false, string $KeyType = false ) | Defines a column to be added to $this->Table(). | |
columnExists ( string $ColumnName ) : boolean | Returns whether or not a column exists in the database. | |
columnTypeString ( mixed $Column ) : string | Return the definition string for a column. | |
columns ( $Name = '' ) : array | An associative array of $ColumnName => $ColumnProperties columns for the table. | |
databasePrefix ( string $DatabasePrefix = '' ) | Gets and/or sets the database prefix. | |
drop ( ) | Drops $this->Table() from the database. | |
dropColumn ( string $Name ) | Drops $Name column from $this->Table(). | |
engine ( $Engine, boolean $CheckAvailability = true ) | ||
existingColumns ( ) : array | Gets the column definitions for the columns in the database. | |
get ( string $TableName = '' ) : Gdn_DatabaseStructure | Load the schema for this table from the database. | |
getAlterTableThreshold ( ) : integer | Get the alter table threshold. | |
getIssues ( ) : array | Get a list of issues that occurred during the last call to {@link Gdn_DatabaseStructure::set()}. | |
getRowCountEstimate ( string $tableName ) : integer | null | Get the estimated number of rows in a table. | |
primaryKey ( string $Name, string $Type = 'int' ) : Gdn_DatabaseStructure | Defines a primary key column on a table. | |
query ( string $sql, boolean $checkTreshold = false ) : Gdn_Dataset | Send a query to the database and return the result. | |
renameColumn ( string $OldName, string $NewName ) | Renames a column in $this->Table(). | |
renameTable ( string $OldName, string $NewName, boolean $UsePrefix = false ) | Renames a table in the database. | |
reset ( ) : Gdn_DatabaseStructure | Reset the internal state of this object so that it can be reused. | |
set ( boolean $Explicit = false, boolean $Drop = false ) | Creates the table and columns specified with $this->Table() and $this->Column(). If no table or columns have been specified, this method will throw a fatal error. | |
setAlterTableThreshold ( integer $alterTableThreshold ) : Gdn_MySQLStructure | Set the alterTableThreshold. | |
table ( string $Name = '', string $CharacterEncoding = '' ) | Specifies the name of the table to create or modify. | |
tableExists ( $TableName = null ) : boolean | Whether or not the table exists in the database. | |
tableName ( ) : string | Returns the name of the table being defined in this object. | |
types ( string $Class = 'all' ) | Gets an array of type names allowed in the structure. | |
view ( string $Name, string $Query ) | Specifies the name of the view to create or modify. |
Method | Description | |
---|---|---|
_create ( ) | Creates the table defined with $this->Table() and $this->Column(). | |
_createColumn ( $Name, $Type, $Null, $Default, $KeyType ) : stdClass | ||
_modify ( boolean $Explicit = false ) | Modifies $this->Table() with the columns specified with $this->Column(). | |
addIssue ( string $message, string $sql ) : Gdn_DatabaseStructure | Add an issue to the issues list. | |
executeQuery ( string $sql, boolean $checkThreshold = false ) : boolean | Send a query to the database and return the result. |
public __construct ( string $Database = null ) | ||
$Database | string |
protected _create ( ) |
protected _createColumn ( $Name, $Type, $Null, $Default, $KeyType ) : stdClass | ||
$Name | ||
$Type | ||
$Null | ||
$Default | ||
$KeyType | ||
return | stdClass |
public column ( string $Name, mixed $Type, boolean $NullDefault = false, string $KeyType = false ) | ||
$Name | string | The name of the column to create. |
$Type | mixed | The data type of the column to be created. Types with a length speecifty the length in barackets. * If an array of values is provided, the type will be set as "enum" and the array will be assigned as the column's Enum property. * If an array of two values is specified then a "set" or "enum" can be specified (ex. array('set', array('Short', 'Tall', 'Fat', 'Skinny'))) |
$NullDefault | boolean | Whether or not nulls are allowed, if not a default can be specified. * TRUE: Nulls are allowed. * FALSE: Nulls are not allowed. * Any other value: Nulls are not allowed, and the specified value will be used as the default. |
$KeyType | string | What type of key is this column on the table? Options are primary, key, and FALSE (not a key). |
public columnExists ( string $ColumnName ) : boolean | ||
$ColumnName | string | The name of the column to check. |
return | boolean |
public columnTypeString ( mixed $Column ) : string | ||
$Column | mixed | The column to get the type string from. - object: The column as returned by the database schema. The properties looked at are Type, Length, and Precision. - string |
return | string | The type definition string. |
public databasePrefix ( string $DatabasePrefix = '' ) | ||
$DatabasePrefix | string |
public dropColumn ( string $Name ) | ||
$Name | string | The name of the column to drop from $this->Table(). |
public existingColumns ( ) : array | ||
return | array |
public getAlterTableThreshold ( ) : integer | ||
return | integer | Returns the threshold as an integer. A value of zero means no threshold. |
public primaryKey ( string $Name, string $Type = 'int' ) : Gdn_DatabaseStructure | ||
$Name | string | The name of the column. |
$Type | string | The data type of the column. |
return | Gdn_DatabaseStructure | $this. |
public renameColumn ( string $OldName, string $NewName ) | ||
$OldName | string | The name of the column to be renamed. |
$NewName | string | The new name for the column being renamed. |
public renameTable ( string $OldName, string $NewName, boolean $UsePrefix = false ) | ||
$OldName | string | The name of the table to be renamed. |
$NewName | string | The new name for the table being renamed. |
$UsePrefix | boolean | A boolean value indicating if $this->_DatabasePrefix should be prefixed before $OldName and $NewName. |
public reset ( ) : Gdn_DatabaseStructure | ||
return | Gdn_DatabaseStructure | $this |
public set ( boolean $Explicit = false, boolean $Drop = false ) | ||
$Explicit | boolean | If TRUE, and the table specified with $this->Table() already exists, this method will remove any columns from the table that were not defined with $this->Column(). |
$Drop | boolean | If TRUE, and the table specified with $this->Table() already exists, this method will drop the table before attempting to re-create it. |
public setAlterTableThreshold ( integer $alterTableThreshold ) : Gdn_MySQLStructure | ||
$alterTableThreshold | integer | |
return | Gdn_MySQLStructure | Returns `$this` for fluent calls. |
public tableExists ( $TableName = null ) : boolean | ||
return | boolean |
public types ( string $Class = 'all' ) | ||
$Class | string | The class of types to get. Valid values are: - int: Integer types. - float: Floating point types. - decimal: Precise decimal types. - numeric: float, int and decimal. - string: String types. - date: Date types. - length: Types that have a length. - precision: Types that have a precision. - other: Types that don't fit into any other category on their own. - all: All recognized types. |
public $CaptureOnly |
protected $_CharacterEncoding |
protected $_ExistingColumns |
protected $_TableExists |