WebFioriAPI ReferenceLearnDownloadContributeLearn{{result.parent_page}} > {{result.title}}{{result.title}}Classes{{result.class_name}}{{result.summary}}Methods{{result.name}}{{result.summary}}

namespace \webfiori\database

abstract class Table

Class Methods Summary

public function __construct(string$name)Creates a new instance of the class.public function addColumn(string$key, Column$colObj)public function addColumns(array$cols)Adds a set of columns as one patch.public function addReference(Table|AbstractQuery|string$refTable, array$cols, string$keyname, string$onupdate, string$ondelete)Adds a foreign key to the table.public function getColByIndex(int$index)Returns a column given its index.public function getColByKey(string$key)Returns a column given its key name.public function getColByName(string$key)Returns a column given its actual name.public function getCols()Returns an associative array that holds all table columns.public function getColsCount()Returns the number of columns which are in the table.public function getColsDatatypes()Returns an array that contains data types of table columns.public function getColsKeys()Returns an indexed array that contains the names of columns keys.public function getColsNames()Returns an array that contains all columns names as they will appear in the database.public function getComment()Returns a string that represents a comment which was added with the table.public function getEntityMapper()Returns an instance of the class 'EntityMapper' which can be used to map the table to an entity class.public function getForeignKey(string$keyName)Returns a foreign key given its name.public function getForignKeys()Returns an array that contains all table foreign keys.public function getForignKeysCount()Returns the number of foreign keys added to the table.public function getName()Returns the name of the table.public function getOldName()Returns the old name of the column.public function getOwner()Returns the database which owns the table.public function getPrimaryKeyColsCount()Returns the number of columns that will act as one primary key.public function getPrimaryKeyColsKeys()Returns an array that contains the keys of the columns which are primary.public function getPrimaryKeyName()Returns the name of table primary key.public function getSelect()public function getUniqueCols()Returns an array that holds all the columns which are set to be unique.public function hasColumn(string$colName)Checks if the table has a column which has specific name.public function hasColumnWithKey(string$keyName)Checks if the table has a column with a given key.public function isNameWithDbPrefix()Checks if table name will be prefixed with database name or not.public function removeColByKey(string$colKey)Removes a column from the table given its key.public function removeReference(string$keyName)Removes a foreign key given its name.public function setComment(string|null$comment)Sets a comment which will appear with the table.public function setName(string$name)Sets the name of the table.public function setOwner(Database|null$db)Sets or removes the database which owns the table.public function setWithDbPrefix(boolean$withDbPrefix)Sets the value of the attributes which determine if table name will be prefixed with database name or not.public abstract function toSQL()

Class Methods Details

public function __construct(string$name)Creates a new instance of the class.

Parameters:

  • string $name The name of the table. If empty string is given, the value 'new_table' will be used as default.
public function addColumn(string$key, Column$colObj)

Parameters:

Returns: boolean
public function addColumns(array$cols)Adds a set of columns as one patch.

Parameters:

  • array $cols An array that holds the columns as an associative array. The indices should represent columns keys.
public function addReference(Table|AbstractQuery|string$refTable, array$cols, string$keyname, string$onupdate, string$ondelete)Adds a foreign key to the table.

Parameters:

  • Table|AbstractQuery|string $refTable The referenced table. It is the table that will contain original values. This value can be an object of type 'Table', an object of type 'AbstractQuery' or the namespace of a class which is a sub-class of the class 'AbstractQuery'.
  • array $cols An associative array that contains key columns. The indices must be names of columns which exist in 'this' table and the values must be columns from referenced table. It is possible to provide an indexed array. If an indexed array is given, the method will assume that the two tables have same column key.
  • string $keyname The name of the key.
  • string $onupdate The 'on update' condition for the key. it can be one of the following:
    • set null
    • cascade
    • restrict
    • set default
    • no action
    Default value is 'set null'.
  • string $ondelete The 'on delete' condition for the key. it can be one of the following:
    • set null
    • cascade
    • restrict
    • set default
    • no action
    Default value is 'set null'.
public function getColByIndex(int$index)Returns a column given its index.

Parameters:

  • int $index The index of the column.
Returns: Column|nullIf a column was found which has the specified index, it is returned. Other than that, The method will return null.
public function getColByKey(string$key)Returns a column given its key name.

Parameters:

  • string $key The name of column key.
Returns: Column|nullIf a column which has the given key exist on the table, the method will return it as an object. Other than that, the method will return null.
public function getColByName(string$key)Returns a column given its actual name.

Parameters:

  • string $key The name of column as it appears in the database.
Returns: Column|nullIf a column which has the given name exist on the table, the method will return it as an object. Other than that, the method will return null.
public function getCols()Returns an associative array that holds all table columns. Returns: arrayAn associative array. The indices of the array are column keys and the values are objects of type 'Column'.public function getColsCount()Returns the number of columns which are in the table. Returns: intThe number of columns in the table.public function getColsDatatypes()Returns an array that contains data types of table columns. Returns: arrayAn indexed array that contains columns data types. Each index will corresponds to the index of the column in the table.public function getColsKeys()Returns an indexed array that contains the names of columns keys. Returns: arrayAn indexed array that contains the names of columns keys.public function getColsNames()Returns an array that contains all columns names as they will appear in the database. Returns: arrayAn array that contains all columns names as they will appear in the database.public function getComment()Returns a string that represents a comment which was added with the table. Returns: string|nullComment text. If it is not set, the method will return null.public function getEntityMapper()Returns an instance of the class 'EntityMapper' which can be used to map the table to an entity class. Note that the developer can modify the name of the entity and the namespace that it belongs to in addition to the path that the class will be created on.Returns: EntityMapperAn instance of the class 'EntityMapper'public function getForeignKey(string$keyName)Returns a foreign key given its name.

Parameters:

  • string $keyName The name of the foreign key as specified when it was added to the table.
Returns: ForeignKey|nullIf a key with the given name exist, the method will return an object that represent it. Other than that, the method will return null.
public function getForignKeys()Returns an array that contains all table foreign keys. Returns: arrayAn array of FKs.public function getForignKeysCount()Returns the number of foreign keys added to the table. Returns: intan integer that represents the count of FKs.public function getName()Returns the name of the table. Returns: stringThe name of the table. Default return value is 'new_table'.public function getOldName()Returns the old name of the column. Note that the old name will be set only if the method Table::setName() is called more than once in the same instance.Returns: string|nullThe method will return a string that represents the old name if it is set. Null if not.public function getOwner()Returns the database which owns the table. Returns: null|DatabaseIf the owner is set, the method will return it as an object. If not set, the method will return null.public function getPrimaryKeyColsCount()Returns the number of columns that will act as one primary key. Returns: intThe number of columns that will act as one primary key. If the table has no primary key, the method will return 0. If one column is used as primary, the method will return 1. If two, the method will return 2 and so on.public function getPrimaryKeyColsKeys()Returns an array that contains the keys of the columns which are primary. Returns: arrayAn array that contains the keys of the columns which are primary.public function getPrimaryKeyName()Returns the name of table primary key. Returns: stringThe returned value will be the name of the table added to it the suffix '_pk'.public function getSelect()Returns: SelectExpression public function getUniqueCols()Returns an array that holds all the columns which are set to be unique. Returns: arrayAn array that holds objects of type 'MSSQLColumn'.public function hasColumn(string$colName)Checks if the table has a column which has specific name.

Parameters:

  • string $colName The name of the column as it appears in database.
Returns: booleanIf the table has such column, the method will return true. other than that, the method will return false.
public function hasColumnWithKey(string$keyName)Checks if the table has a column with a given key.

Parameters:

  • string $keyName The name of the key.
Returns: booleanIf a column with the given key exist, the method will return true. Other than that, the method will return false.
public function isNameWithDbPrefix()Checks if table name will be prefixed with database name or not. Returns: booleanTrue if it will be prefixed. False if not.public function removeColByKey(string$colKey)Removes a column from the table given its key.

Parameters:

  • string $colKey Key name of the column.
Returns: Column|nullIf the column is removed, an object that represent it is returned. Other than that, the method will return null.
public function removeReference(string$keyName)Removes a foreign key given its name.

Parameters:

  • string $keyName The name of the foreign key.
Returns: ForeignKey|nullIf the key was removed, the method will return the removed key as an object. If nothing changed, the method will return null.
public function setComment(string|null$comment)Sets a comment which will appear with the table.

Parameters:

  • string|null $comment Comment text. It must be non-empty string in order to set. If null is passed, the comment will be removed.
public function setName(string$name)Sets the name of the table.

Parameters:

  • string $name The name of the table. Must be non-empty string in order to set.
Returns: booleanIf the name is set, the method will return true. Other than that, the method will return false.
public function setOwner(Database|null$db)Sets or removes the database which owns the table.

Parameters:

  • Database|null $db The owner database. If null is passed, the owner will be unset.
public function setWithDbPrefix(boolean$withDbPrefix)Sets the value of the attributes which determine if table name will be prefixed with database name or not. Note that table name will be prefixed with database name only if owner schema is set.

Parameters:

  • boolean $withDbPrefix True to prefix table name with database name. false to not prefix table name with database name.
public abstract function toSQL()
mdi-menuAll Classesmdi-chevron-leftAnchorBrCodeSnippetHTMLDocHTMLListHTMLNodeHTMLTableHeadNodeInputJsCodeLabelListItemOrderedListParagraphRadioGroupTableCellTableRowUnorderedListInvalidNodeNameExceptionTemplateNotFoundExceptionCaseConverterJsonJsonConverterJsonIJsonTypesPropertyAPIFilterAbstractWebServiceManagerInfoServiceParamTypesRequestRequestParameterResponseUriWebServicesManagerAccessAutoLoaderConfigConfigControllerDBEAbstractWebServiceExtendedWebServicesManagerFileLoggerPrivilegePrivilegesGroupThemeThemeLoaderUploadFileUploaderUserUtilWebFioriAppLanguageErrorBoxHTTPCodeViewMessageBoxServerErrViewStarterPageWebPageDatabaseSessionStorageDefaultSessionStorageMSSQLSessionDataTableMSSQLSessionsTableMySQLSessionDataTableMySQLSessionsTableSessionSessionOperationsSessionStorageSessionsManagerRouterRouterUriAbstractMiddlewareMiddlewareManagerEmailMessageSMTPAccountSMTPServerClassLoaderExceptionFileExceptionInitializationExceptionInvalidCRONExprExceptionMissingLangExceptionNoSuchThemeExceptionRoutingExceptionSMTPExceptionSessionExceptionUIExceptionAbstractJobCronCronEmailCronJobJobArgumentCronLoginViewCronTasksViewCronViewCronLoginServiceCronLogoutServiceCronServicesManagerForceCronExecutionServiceGetJobsServiceCLICLICommandInputStreamOutputStreamStdInStdOutClassWriterLangClassWriterQueryClassWriterServiceHolderThemeClassWriterWebServiceWriterCreateCLIClassHelperCreateCronJobCreateMiddlewareCreateTableCreateTableObjCreateThemeHelperCreateWebServiceAddCommandCreateCommandCronCommandHelpCommandListCronCommandListRoutesCommandListThemesCommandRunSQLQueryCommandSettingsCommandTestRouteCommandUpdateSettingsCommandUpdateTableCommandVersionCommandAbstractQueryColumnColumnFactoryConditionConnectionConnectionInfoDatabaseDatabaseExceptionDateTimeValidatorEntityMapperExpressionForeignKeyJoinTableResultSetSelectExpressionTableWhereExpressionMySQLColumnMySQLConnectionMySQLQueryMySQLTableMSSQLColumnMSSQLConnectionMSSQLQueryMSSQLTableAbstractCollectionComparableLinkedListNodeQueueStack
Powered By: WebFiori Framework, Vue and VuetifyAll Rights Reserved © 2018 - 2024