YANA 4 PHP Framework
Docs For Class StructureFile
database schema file
This wrapper class represents the structure of a database
Located in /includes/class_structurefile.php
Object | --InputStream | --SecureInputStream | --SecureFileStream | --SML | --StructureFile
Name | Type | Description |
---|---|---|
$filename | string |
Create a new instance of this class.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns bool(true) on success and bool(false) otherwise.
Name | Type | Description |
---|---|---|
$filename | string |
This function merges the contents of another file with the current structure.
Note that you can reach the same result by using the 'INCLUDE' tag in the structure file. See the developer's cookbook for an example.
Name | Type | Description |
---|---|---|
$table | string |
Returns bool(true) on success and bool(false) otherwise.
Name | Type | Description |
---|---|---|
$table | string | |
&$row | mixed | |
$is_insert | bool |
Returns bool(true) if $row is valid and bool(false) otherwise.
Name | Type | Description |
---|---|---|
$table | string |
Returns a numeric array of all columns in $table. Issues an E_USER_NOTICE and returns an empty array, if $table does not exist in current structure file.
Name | Type | Description |
---|---|---|
$table | string | |
$type | string |
Returns false if the table does not exist. Otherwise it returns a list of column names.
Name | Type | Description |
---|---|---|
$operation | string | one of select, insert, update, delete |
$table | string | |
$columns | array | (optional) |
Retrieves all "constraint" entries that apply to the given operation on the dataset and returns the results as an numeric array.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns constant NULL (not bool(false)) if value is not specified. Use is_null($result) to test for existance, don't use empty($result).
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns the description text (=comment) of $column in $table as a string or bool(false) if none exists.
Name | Type | Description |
---|---|---|
$table | string |
Returns false if the table does not exist. Otherwise it returns a list of column names.
Name | Type | Description |
---|---|---|
$table | string |
Returns an associative array of foreign keys. If $table is not a specified in the current structure file, then NULL is returned instead. If the table has no foreign keys, an empty array is returned.
Note that this operation is not case sensitive.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns an array of the following values:
- array (
- 'size' : int, // maximum size in bytes
- 'width' : int, // horizontal dimension in px
- 'height' : int, // vertical dimension in px
- 'ratio' : bool, // keep aspect-ratio (true=yes, false=no)
- 'background' : array(red, green, blue) // color of canvas
- )
Name | Type | Description |
---|---|---|
$table | string |
Returns a numeric array of all columns in $table, that are marked with the option INDEX => true (which means, all columns that have an index).
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns the 'length' attribute of $column in $table. Returns int(0) if there is no $table, or the table has no column named $column, or the column does not have a 'length' attribute.
Name | Type | Description |
---|---|---|
$table | string |
Returns the name of the primary key column of $table as a lower-cased string. Returns NULL and issues an E_USER_WARNING if $table is not a listed table in the current structure file. Returns NULL and issues an E_USER_WARNING if there is no primary key for $table.
Name | Type | Description |
---|---|---|
$table | string |
Returns the name of a column that is supposed to contain the profile id (if any).
If no table named $table is listed in the current structure file or $table does not have a column using a profile id, or the specified column does not exist, the function returns bool(false).
Returns the text of the source file containing the database structure as a string or bool(false) on error.
Name | Type | Description |
---|---|---|
$table | string | |
$foreignKey | string |
Returns a numeric array of all tables in the current structure file. Issues an E_USER_NOTICE and returns an empty array, if the list of tables is empty.
Name | Type | Description |
---|---|---|
$prefix | int | currently one of YANA_TRIGGER_BEFORE, YANA_TRIGGER_AFTER |
$operation | string | one of insert, update, delete |
$table | string | |
$columns | array |
Retrieves all "trigger" entries that apply to the given operation on the dataset and returns the results as an numeric array.
There are two constants to use for argument $prefix: The first, YANA_TRIGGER_BEFORE, refers to triggers that fire BEFORE the action $operation is carried out. And YANA_TRIGGER_AFTER, refers to triggers that fire AFTER the action $operation has been carried out.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns the 'type' attribute of $column in $table as a lower-cased string. Returns string("") if there is no $table, or the table has no column named $column, or the column does not have a 'type' attribute.
Name | Type | Description |
---|---|---|
$table | string |
Returns a numeric array of all columns in $table, that are marked with the option UNQIUE => true (which means, all columns that have an unique constraint).
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns bool(true) if a table named $table is listed in the current structure file and it has a column named $column, which has an index. Returns bool(false) otherwise. Note that this operation is not case sensitive.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns bool(true) if a table named $table is listed in the current structure file and it has a column named $column that uses the autofill feature. Returns bool(false) otherwise. Note that this operation is not case sensitive.
Autofill is activated by setting the property "REQUIRED" to "AUTO".
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns bool(true) if a table named $table is listed in the current structure file and it has a column named $column that is an autonumber colummn. Returns bool(false) otherwise. Note that this operation is not case sensitive.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns bool(true) if a table named $table is listed in the current structure file and it has a column named $column in its list of contents. Returns bool(false) otherwise. Note that this operation is not case sensitive.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string | |
$action | string |
Returns bool(true) if:
If the argument $action is not provided, the last two do not apply.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns bool(true) if a table named $table is listed in the current structure file and it has a column named $column in its list of foreign keys. Returns bool(false) otherwise. Note that this operation is not case sensitive.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns bool(true) if a table named $table is listed in the current structure file and it has a column named $column that allows undefined values (NULL). Returns bool(false) otherwise. Note that this operation is not case sensitive.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns bool(true) if a table named $table is listed in the current structure file and its primary key is named $column. Returns bool(false) otherwise. Note that this operation is not case sensitive.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns bool(true) if:
Returns bool(false) otherwise.
Name | Type | Description |
---|---|---|
$table | string |
Returns bool(true) if a table with the given name is listed in the current structure file and bool(false) otherwise. Note that this operation is not case sensitive.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Returns bool(true) if a table named $table is listed in the current structure file, it has a column named $column in its list of contents and this column has a unique constraint. Returns bool(false) otherwise. Note that this operation is not case sensitive.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string | |
$action | string |
Returns bool(true) if:
If the argument $action is not provided, the last two do not apply.
Always call this first before anything else. Returns the file content on success and bool(false) on error.
Redefinition of: SML::read()
Name | Type | Description |
---|---|---|
$table | string | |
$column | string | |
$isNullable | bool |
Sets the property "required" of the selected column to the value "auto".
This enables the "autofill" feature, which is available for columns of several types. On columns of type "integer" it mimics MySQL's "auto increment" feature. On columns of type "ip" it enters the visitor's remote address (IP) automatically. For type "time" it enters the current server time.
However: you should note, that the user input takes precedence over the autofill feature, which defines a default value.
Note: this function does not check wether "autofill" does "make sense" for the type of column you selected. It also does not clear the "default" property of the column, if any.
Returns bool(false) if the table or column does not exist.
Name | Type | Description |
---|---|---|
$constraint | string | PHP-Code |
$operation | string | one of select, insert, update, delete |
$table | string | |
$column | string |
Returns bool(true) on success and bool(false) on error.
Note: This function will check some syntax of your code. However, it can't ensure that your codes makes sense. So keep in mind that it is your job in the first place to ensure the constraint is valid!
BE WARNED: As always - do NOT use this function with any unchecked user input.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string | |
$value | midex |
Name | Type | Description |
---|---|---|
$table | string | |
$column | string | |
$description | string |
Returns bool(true) on success and bool(false) on error.
A description is the "label" of a column. A human-readable small phrase that should tell readers what it is.
Note: though you may take any length of text you want, you are best adviced to use really short phrases like 'name', 'address' or 'phone' as a description.
Name | Type | Description |
---|---|---|
$isEditable | bool | |
$table | string | |
$column | string | |
$action | string |
This sets the "display.readonly" property of the column to bool(false), if $isEditable is bool(true) and vice versa.
Returns bool(true) on success and bool(false) on error.
Note: if you don't provide the attribute $action then settings will apply to all actions. Otherwise you need to set the display property for all actions separately.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string | |
$ftable | string |
To unset, leave $ftable blank.
Returns bool(true) on success and bool(false) on error.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string | |
$settings | array |
The argument $settings is an array of the following values:
- array (
- 'size' : int, // maximum size in bytes
- 'width' : int, // horizontal dimension in px
- 'height' : int, // vertical dimension in px
- 'ratio' : bool, // keep aspect-ratio (true=yes, false=no)
- 'background' : array(red, green, blue) // color of canvas
- )
Name | Type | Description |
---|---|---|
$table | string | |
$column | string | |
$hasIndex | bool |
Returns bool(true) on success and bool(false) on error.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string | |
$length | int |
Returns bool(true) on success and bool(false) on error.
The argument $length must be a positive integer.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string | |
$isNullable | bool |
Sets the "required" property of the column. If the argument $isNullable is bool(true), then "required" is set to false. Otherwise it is set to true.
If the table or column is not defined, the function returns bool(false). Otherwise it returns bool(true).
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Select $column as the primary key of $table. Returns bool(true) on success and bool(false) on error.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
To unset, leave $column blank.
Returns bool(true) on success and bool(false) on error.
Name | Type | Description |
---|---|---|
$isReadonly | bool | |
$table | string | |
$column | string |
Returns bool(true) on success and bool(false) otherwise.
Name | Type | Description |
---|---|---|
$isStrict | bool |
Set the property "USE_STRICT" of the database file to the argument $isStrict;
Name | Type | Description |
---|---|---|
$trigger | string | PHP-Code |
$prefix | int | currently one of YANA_TRIGGER_BEFORE, YANA_TRIGGER_AFTER |
$operation | string | one of select, insert, update, delete |
$table | string | |
$column | string |
Returns bool(true) on success and bool(false) on error.
Note: This function will check some syntax of your code. However, it can't ensure that your codes makes sense. So keep in mind that it is your job in the first place to ensure the constraint is valid!
BE WARNED: As always - do NOT use this function with any unchecked user input.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string | |
$value | midex |
Note: this function does not check if the provided string is a valid type name.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string | |
$isUnique | bool |
Returns bool(true) on success and bool(false) otherwise.
Note: you don't need to set a "unique" constraint on a primary key. A "primary key" column always requires its values to be unique.
Primary keys implicitely have a unique constraint.
Name | Type | Description |
---|---|---|
$isVisible | bool | |
$table | string | |
$column | string | |
$action | string |
This sets the property "display.hidden" of the column to bool(true), if $isVisible is bool(false) and vice versa.
Returns bool(true) on success and bool(false) on error.
Note: if you don't provide the attribute $action then settings will apply to all actions. Otherwise you need to set the display property for all actions separately.
Name | Type | Description |
---|---|---|
$table | string | |
$column | string | |
$value | mixed | |
$escape | int |
Inherited From SML
Inherited From SecureFileStream
Inherited From SecureInputStream
Inherited From InputStream
Inherited From Object
Documentation generated on Sun, 11 Mar 2007 15:02:47 +0100 by phpDocumentor 1.3.1