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

namespace \webfiori\database\mssql

class MSSQLColumn

Class Methods Summary

public function __construct(string$name, string$datatype, int$size)Creates new instance of the class.public function __toString()public function asString()public function cleanValue(mixed$val)Validates and cleans a value for usage in a query.public static function createColObj(array$options)Creates an instance of the class 'Column' given an array of options.public function getAlias()Returns column alias.public function getDefault()Returns the default value of the column.public function getName()Returns the name of the column.public function getPHPType()Returns a string that represents the datatype of column data in PHP.public function isAutoUpdate()Returns the value of the property 'isAutoUpdate'.public function setAutoUpdate(boolean$bool)Sets the value of the property 'isAutoUpdate'.public function setDefault(mixed$default)Sets the default value for the column to use in case of insert.public function setScale(int$val)Sets the value of Scale.

Class Methods Details

public function __construct(string$name, string$datatype, int$size)Creates new instance of the class.

Parameters:

  • string $name The unique name of the column.
  • string $datatype The datatype of the column. Default value is 'nvarchar'
  • int $size The size of the column. Used only if column type supports size.
public function __toString()public function asString()public function cleanValue(mixed$val)Validates and cleans a value for usage in a query.

Parameters:

  • mixed $val The value that will be cleaned.
Returns: mixedThe method will return a value which is based on applied filters and the datatype of the column.
public static function createColObj(array$options)Creates an instance of the class 'Column' given an array of options.

Parameters:

  • array $options An associative array of options. The available options are:
    • name: Required. The name of the column in the database. If not provided, no object will be created.
    • datatype: The datatype of the column. If not provided, 'varchar' will be used. Equal option: 'type'.
    • size: Size of the column (if datatype does support size). If not provided, 1 will be used.
    • default: A default value for the column if its value is not present in case of insert.
    • is-null: A boolean. If the column allows null values, this should be set to true. Default is false.
    • is-primary: A boolean. It must be set to true if the column represents a primary key. Note that the column will be set as unique once its set as a primary. Equal option: primary.
    • is-unique: A boolean. If set to true, a unique index will be created for the column.
    • auto-update: A boolean. If the column datatype is 'date', 'time' or 'datetime2' and this parameter is set to true, the time of update will change automatically without having to change it manually.
    • scale: Number of numbers to the left of the decimal point. Only supported for decimal datatype.
    • comment: A comment which can be used to describe the column.
    • validator: A PHP function which can be used to validate user values before submitting the query to database.
Returns: MSSQLColumn|nullThe method will return an object of type 'MySQLColumn' if created. If the index 'name' is not set, the method will return null.
public function getAlias()Returns column alias. Note that the method will add square brackets around the alias.Returns: string|nullName alias.public function getDefault()Returns the default value of the column. Note that for 'datetime' and 'timestamp', if default value is set to 'now()' or 'current_timestamp', the method will return a date string in the format 'YYYY-MM-DD HH:MM:SS' that represents current time.Returns: mixedThe default value of the column.public function getName()Returns the name of the column. Note that the method will add square brackets around the name.Returns: stringThe name of the column.public function getPHPType()Returns a string that represents the datatype of column data in PHP. This method basically maps the data that can be stored in a column from MySQL type to PHP type. For example, if column type is 'varchar', the method will return the value 'string'. If the column allow null values, the method will return 'string|null' and so on.Returns: stringA string that represents column type in PHP (such as 'integer' or 'boolean').public function isAutoUpdate()Returns the value of the property 'isAutoUpdate'. Returns: booleanIf the column type is 'datetime' or 'timestamp' and the column is set to auto update in case of update query, the method will return true. Default return value is valse.public function setAutoUpdate(boolean$bool)Sets the value of the property 'isAutoUpdate'. It is used in case the user want to update the date of a column that has the type 'datetime' or 'timestamp' automatically if a record is updated. This method has no effect for other datatypes.

Parameters:

  • boolean $bool If true is passed, then the value of the column will be updated in case an update query is constructed.
public function setDefault(mixed$default)Sets the default value for the column to use in case of insert. For integer data type, the passed value must be an integer. For string , the passed value must be a string. If the datatype is 'datetime2', the default will be set to current time and date if non-null value is passed (the value which is returned by the function date('Y-m-d H:i:s). If the passed value is a date string in the format 'YYYY-MM-DD HH:MM:SS', then it will be set to the given value. If the passed value is a date string in the format 'YYYY-MM-DD', then the default will be set to 'YYYY-MM-DD 00:00:00'. If null is passed, it implies that no default value will be used.

Parameters:

  • mixed $default The default value which will be set.
public function setScale(int$val)Sets the value of Scale. Scale is simply the number of digits that will appear to the right of decimal point. Only applicable if the datatype of the column is decimal, float and double.

Parameters:

  • int $val Number of numbers after the decimal point. It must be a positive number.
Returns: booleanIf scale value is set, the method will return true. false otherwise. The method will not set the scale in the following cases:
  • Datatype of the column is not decimal, float or double.
  • Size of the column is 0.
  • Given scale value is greater than the size of the column.
mdi-menuAll Classesmdi-chevron-leftAnchorBrCodeSnippetHTMLDocHTMLListHTMLNodeHTMLTableHeadNodeInputJsCodeLabelListItemOrderedListParagraphRadioGroupTableCellTableRowUnorderedListInvalidNodeNameExceptionTemplateNotFoundExceptionCaseConverterJsonJsonConverterJsonIJsonTypesPropertyAPIFilterAbstractWebServiceManagerInfoServiceParamTypesRequestRequestParameterResponseUriWebServicesManagerAccessAutoLoaderConfigConfigControllerDBEAbstractWebServiceExtendedWebServicesManagerFileLoggerPrivilegePrivilegesGroupThemeThemeLoaderUploadFileUploaderUserUtilWebFioriAppLanguageErrorBoxHTTPCodeViewMessageBoxServerErrViewStarterPageWebPageDatabaseSessionStorageDefaultSessionStorageMSSQLSessionDataTableMSSQLSessionsTableMySQLSessionDataTableMySQLSessionsTableSessionSessionOperationsSessionStorageSessionsManagerRouterRouterUriAbstractMiddlewareMiddlewareManagerEmailMessageSMTPAccountSMTPServerClassLoaderExceptionFileExceptionInitializationExceptionInvalidCRONExprExceptionMissingLangExceptionNoSuchThemeExceptionRoutingExceptionSMTPExceptionSessionExceptionUIExceptionAbstractJobCronCronEmailCronJobJobArgumentCronLoginViewCronTasksViewCronViewCronLoginServiceCronLogoutServiceCronServicesManagerForceCronExecutionServiceGetJobsServiceCLICLICommandInputStreamOutputStreamStdInStdOutClassWriterLangClassWriterQueryClassWriterServiceHolderThemeClassWriterWebServiceWriterCreateCLIClassHelperCreateCronJobCreateMiddlewareCreateTableCreateTableObjCreateThemeHelperCreateWebServiceAddCommandCreateCommandCronCommandHelpCommandListCronCommandListRoutesCommandListThemesCommandRunSQLQueryCommandSettingsCommandTestRouteCommandUpdateSettingsCommandUpdateTableCommandVersionCommandAbstractQueryColumnColumnFactoryConditionConnectionConnectionInfoDatabaseDatabaseExceptionDateTimeValidatorEntityMapperExpressionForeignKeyJoinTableResultSetSelectExpressionTableWhereExpressionMySQLColumnMySQLConnectionMySQLQueryMySQLTableMSSQLColumnMSSQLConnectionMSSQLQueryMSSQLTableAbstractCollectionComparableLinkedListNodeQueueStack
Powered By: WebFiori Framework, Vue and VuetifyAll Rights Reserved © 2018 - 2024