PHP 클래스 Gdn_DatabaseStructure, vanilla

파일 보기 프로젝트 열기: vanilla/vanilla 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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.

보호된 프로퍼티들

프로퍼티 타입 설명
$_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.

공개 메소드들

메소드 설명
__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.

보호된 메소드들

메소드 설명
_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.

메소드 상세

__construct() 공개 메소드

The constructor for this class. Automatically fills $this->ClassName.
public __construct ( string $Database = null )
$Database string

_create() 보호된 메소드

Creates the table defined with $this->Table() and $this->Column().
protected _create ( )

_createColumn() 보호된 메소드

protected _createColumn ( $Name, $Type, $Null, $Default, $KeyType ) : stdClass
$Name
$Type
$Null
$Default
$KeyType
리턴 stdClass

_modify() 보호된 메소드

Modifies $this->Table() with the columns specified with $this->Column().
protected _modify ( boolean $Explicit = false )
$Explicit boolean If TRUE, this method will remove any columns from the table that were not defined with $this->Column().

addIssue() 보호된 메소드

Add an issue to the issues list.
protected addIssue ( string $message, string $sql ) : Gdn_DatabaseStructure
$message string A human readable string for the issue.
$sql string The SQL that didn't happen.
리턴 Gdn_DatabaseStructure Returns **this** for chaining.

column() 공개 메소드

Defines a column to be added to $this->Table().
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).

columnExists() 공개 메소드

Returns whether or not a column exists in the database.
public columnExists ( string $ColumnName ) : boolean
$ColumnName string The name of the column to check.
리턴 boolean

columnTypeString() 공개 메소드

Return the definition string for a column.
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
리턴 string The type definition string.

columns() 공개 메소드

An associative array of $ColumnName => $ColumnProperties columns for the table.
public columns ( $Name = '' ) : array
리턴 array

databasePrefix() 공개 메소드

Gets and/or sets the database prefix.
public databasePrefix ( string $DatabasePrefix = '' )
$DatabasePrefix string

drop() 공개 메소드

Drops $this->Table() from the database.
public drop ( )

dropColumn() 공개 메소드

Drops $Name column from $this->Table().
public dropColumn ( string $Name )
$Name string The name of the column to drop from $this->Table().

engine() 공개 메소드

public engine ( $Engine, boolean $CheckAvailability = true )
$Engine
$CheckAvailability boolean

executeQuery() 보호된 메소드

Send a query to the database and return the result.
protected executeQuery ( string $sql, boolean $checkThreshold = false ) : boolean
$sql string The sql to execute.
$checkThreshold boolean Whether or not to check the alter table threshold before altering the table.
리턴 boolean Whether or not the query succeeded.

existingColumns() 공개 메소드

Gets the column definitions for the columns in the database.
public existingColumns ( ) : array
리턴 array

get() 공개 메소드

Load the schema for this table from the database.
public get ( string $TableName = '' ) : Gdn_DatabaseStructure
$TableName string The name of the table to get or blank to get the schema for the current table.
리턴 Gdn_DatabaseStructure $this

getAlterTableThreshold() 공개 메소드

The alter table threshold is the maximum estimated rows a table can have where alter tables are allowed.
public getAlterTableThreshold ( ) : integer
리턴 integer Returns the threshold as an integer. A value of zero means no threshold.

getIssues() 공개 메소드

Get a list of issues that occurred during the last call to {@link Gdn_DatabaseStructure::set()}.
public getIssues ( ) : array
리턴 array Returns an array of issues.

getRowCountEstimate() 공개 메소드

Get the estimated number of rows in a table.
public getRowCountEstimate ( string $tableName ) : integer | null
$tableName string The name of the table to look up, without its prefix.
리턴 integer | null Returns the estimated number of rows or **null** if the information doesn't exist.

primaryKey() 공개 메소드

Defines a primary key column on a table.
public primaryKey ( string $Name, string $Type = 'int' ) : Gdn_DatabaseStructure
$Name string The name of the column.
$Type string The data type of the column.
리턴 Gdn_DatabaseStructure $this.

query() 공개 메소드

Send a query to the database and return the result.
사용 중단: since 2.3. Was incorrectly public. Replaced by executeQuery().
public query ( string $sql, boolean $checkTreshold = false ) : Gdn_Dataset
$sql string The sql to execute.
$checkTreshold boolean Should not be used
리턴 Gdn_Dataset

renameColumn() 공개 메소드

Renames a column in $this->Table().
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.

renameTable() 공개 메소드

Renames a table in the database.
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.

reset() 공개 메소드

Reset the internal state of this object so that it can be reused.
public reset ( ) : Gdn_DatabaseStructure
리턴 Gdn_DatabaseStructure $this

set() 공개 메소드

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.
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.

setAlterTableThreshold() 공개 메소드

Set the alterTableThreshold.
public setAlterTableThreshold ( integer $alterTableThreshold ) : Gdn_MySQLStructure
$alterTableThreshold integer
리턴 Gdn_MySQLStructure Returns `$this` for fluent calls.

table() 공개 메소드

Specifies the name of the table to create or modify.
public table ( string $Name = '', string $CharacterEncoding = '' )
$Name string The name of the table.
$CharacterEncoding string The default character encoding to specify for this table.

tableExists() 공개 메소드

Whether or not the table exists in the database.
public tableExists ( $TableName = null ) : boolean
리턴 boolean

tableName() 공개 메소드

Returns the name of the table being defined in this object.
public tableName ( ) : string
리턴 string

types() 공개 메소드

Gets an array of type names allowed in the structure.
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.

view() 공개 메소드

Specifies the name of the view to create or modify.
public view ( string $Name, string $Query )
$Name string The name of the view.
$Query string Query to create as the view. Typically this can be generated with the $Database object.

프로퍼티 상세

$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.
public $CaptureOnly

$Database 공개적으로 프로퍼티

The instance of the database singleton.
public $Database

$_CharacterEncoding 보호되어 있는 프로퍼티

The character encoding to set as default for the table being created.
protected $_CharacterEncoding

$_Columns 보호되어 있는 프로퍼티

protected array $_Columns
리턴 array

$_DatabasePrefix 보호되어 있는 프로퍼티

protected string $_DatabasePrefix
리턴 string

$_ExistingColumns 보호되어 있는 프로퍼티

The existing columns in the database.
protected $_ExistingColumns

$_TableExists 보호되어 있는 프로퍼티

Whether or not this table exists in the database.
protected $_TableExists

$_TableName 보호되어 있는 프로퍼티

The name of the table to create or modify.
protected $_TableName

$_TableStorageEngine 보호되어 있는 프로퍼티

The name of the storage engine for this table.
protected $_TableStorageEngine