>> YANA 4 PHP Framework >> Docs For Class StructureFile

Class StructureFile

Description

database schema file

This wrapper class represents the structure of a database

  • access: public

Located in /includes/class_structurefile.php

Object
   |
   --InputStream
      |
      --SecureInputStream
         |
         --SecureFileStream
            |
            --SML
               |
               --StructureFile
Method Summary

Methods

constructor
StructureFile StructureFile (
string $filename
)
List of parameters:
Name Type Description
$filename string
Description:

Create a new instance of this class.

include structure file
bool addFile (
string $filename
)
List of parameters:
Name Type Description
$filename string
Description:

merges the contents of another file with the current structure

  • access: public
validate a row against the schema
boolean checkRow (
string $table, string &$row, [ $is_insert = true]
)
List of parameters:
Name Type Description
$table string
&$row string
$is_insert
Description:

Returns bool(true) if $row is valid and bool(false) otherwise.

  • access: public
get the names of all columns in a table
array getColumns (
string $table
)
List of parameters:
Name Type Description
$table string
Description:

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.

  • access: public
get all constraints for an address
array getConstraint (
string $operation, string $table, [array $columns = array()]
)
List of parameters:
Name Type Description
$operation string one of select, insert, update, delete
$table string
$columns array (optional)
Description:

Retrieves all "constraint" entries that apply to the given operation on the dataset and returns the results as an numeric array.

  • since: version 2.8.4
  • access: public
get the default value of a field as specified in the structure
mixed getDefault (
string $table, string $column
)
List of parameters:
Name Type Description
$table string
$column string
Description:

Returns constant NULL (not bool(false)) if value is not specified. Use is_null($result) to test for existance, don't use empty($result).

  • access: public
return a list of foreign keys defined on a table
array getForeignKeys (
string $table
)
List of parameters:
Name Type Description
$table string
Description:

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.

  • access: public
get a list of all indexed columns in a table
array getIndexes (
string $table
)
List of parameters:
Name Type Description
$table string
Description:

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

  • since: 2.8.5
  • access: public
get the maximum length of a field as specified in the structure
int getLength (
string $table, string $column
)
List of parameters:
Name Type Description
$table string
$column string
Description:

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.

  • access: public
get the primary key of a table
string getPrimaryKey (
string $table
)
List of parameters:
Name Type Description
$table string
Description:

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.

  • access: public
get the file source
mixed getSource ()
Description:

Returns the text of the source file containing the database structure as a string or bool(false) on error.

  • access: public
get the compiled structure of the database
mixed getStructure ()
Description:
  • access: public
get the name of the table, a foreign key points to
string getTableByForeignKey (
string $table, string $foreignKey
)
List of parameters:
Name Type Description
$table string
$foreignKey string
Description:
  • access: public
get a list of all tables in the current database
array getTables ()
Description:

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.

  • access: public
get all triggers for an address
array getTrigger (
int $prefix, string $operation, string $table, [array $columns = array()]
)
List of parameters:
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 (optional)
Description:

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.

  • since: version 2.8.5
  • access: public
get the data type of a field as specified in the structure
string getType (
string $table, string $column
)
List of parameters:
Name Type Description
$table string
$column string
Description:

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.

  • access: public
get a list of all unique columns in table
array getUniqueConstraints (
string $table
)
List of parameters:
Name Type Description
$table string
Description:

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

  • since: 2.8.5
  • access: public
check whether a column is indexed in the current structure
boolean hasIndex (
string $table, string $column
)
List of parameters:
Name Type Description
$table string
$column string
Description:

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.

  • since: 2.8.5
  • access: public
initialize the file
boolean init ()
Description:

Always call this first before anything else.

  • access: public

Redefinition of: SML::init()

check whether a column exists in the current structure
boolean isColumn (
string $table, string $column
)
List of parameters:
Name Type Description
$table string
$column string
Description:

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.

  • access: public
check whether a foreign key exists in the current structure
boolean isForeignKey (
string $table, string $column
)
List of parameters:
Name Type Description
$table string
$column string
Description:

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.

  • access: public
check whether a primary key exists in the current structure
boolean isPrimaryKey (
string $table, string $column
)
List of parameters:
Name Type Description
$table string
$column string
Description:

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.

  • access: public
check whether the "READONLY" flag is set to bool(true)
boolean isReadonly (
[string $table = ""], [string $column = ""]
)
List of parameters:
Name Type Description
$table string
$column string
Description:

Returns bool(true) if:

  1. database is set to 'readonly=true', or
  2. $table is set to 'readonly=true', or
  3. $column in $table is set to 'readonly=true'

Returns bool(false) otherwise.

  • access: public
check whether the structure defines the "USE_STRICT" setting as bool(true)
boolean isStrict ()
Description:
  • access: public
check whether a table exists in the current structure
boolean isTable (
string $table
)
List of parameters:
Name Type Description
$table string
Description:

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.

  • access: public
check whether a column has a unique constraint
boolean isUnique (
string $table, string $column
)
List of parameters:
Name Type Description
$table string
$column string
Description:

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.

  • since: 2.8.5
  • access: public
untaint user input data with the help of the schema
mixed untaintInput (
string $table, string $column, mixed $value, [int $escape = YANA_ESCAPE_NONE]
)
List of parameters:
Name Type Description
$table string
$column string
$value mixed
$escape int
Description:
  • access: public
inherited from base classes

Inherited From SML

Inherited From SecureFileStream

Inherited From SecureInputStream

Inherited From InputStream

Inherited From Object

Documentation generated on Wed, 22 Nov 2006 20:19:18 +0100 by phpDocumentor 1.3.1

yana author: Thomas MeyerHomepage: www.all-community.de/pub