![]() |
Xataface 2.0
Xataface Application Framework
|
Public Member Functions | |
Dataface_Table_builder ($name) | |
createPrimaryKey () | |
& | keys () |
save () | |
create () | |
update () | |
alterFieldInDB ($field, $op='modify') | |
addFieldToDB ($field) | |
removeFieldFromDB ($field) | |
writeConfigFiles ($params=array()) | |
flattenConfigArray ($field, &$arr, $prefix='') | |
compareFields ($field1, $field2) | |
& | fields () |
& | addField ($field) |
removeField ($name) | |
& | getField ($name) |
getParameter ($fieldname, $paramname) | |
setParameter ($fieldname, $paramname, $paramvalue) | |
Data Fields | |
$table | |
$name | |
$fields = array() |
Handles the building of database tables and their associated configuration files. This version is only support the fields.ini file, but future versions will support relationships and valuelists.
Usage: $builder = new Dataface_Table_builder('mytable'); $builder->addField( array( 'Field'=>'id', 'Type'=>'int(11)', 'Extra'=>'auto_increment', 'Null'=>'' ) ); $builder->addField( array( 'Field'=>'title', 'Type'=>'varchar(64)', ) ); $builder->save(); // saves the table to the database and the config files to disk.
Definition at line 30 of file builder.php.
& addField | ( | $ | field | ) |
Adds a field to this table.
array | $field | A partial field definition. Must contain at least Field (or name) and Type keys. |
string | $field,[Field] | The name of the field |
string | $field,[Type] | The type of the field (e.g. int(11)) |
string | $field,[Default] | The default value |
string | $field,[Key] | 'PRI' if this is part of the primary key. |
string | $field,[Null] | Empty if the field is not null. |
Definition at line 305 of file builder.php.
addFieldToDB | ( | $ | field | ) |
Adds a field to the table.
array | $field | The field definition to add. |
Definition at line 195 of file builder.php.
alterFieldInDB | ( | $ | field, |
$ | op = 'modify' |
||
) |
Alters a field.
array | $field | The field definition to be modified. |
string | $op | The operation to perform. Can take values 'add' or 'modify'. |
Definition at line 172 of file builder.php.
compareFields | ( | $ | field1, |
$ | field2 | ||
) |
Compares two field definitions to make sure that they are identical.
array | $field1 | Associative array representing a field. |
array | $field2 | Associative array representing b field. |
Definition at line 276 of file builder.php.
create | ( | ) |
Creates a table in the database based on the name and field definitions in the builder. This also sets the table property to a Dataface_Table object for the created table.
Definition at line 99 of file builder.php.
createPrimaryKey | ( | ) |
Definition at line 53 of file builder.php.
Dataface_Table_builder | ( | $ | name | ) |
Definition at line 44 of file builder.php.
& fields | ( | ) |
Obtains a reference to the fields array for this table.
Definition at line 288 of file builder.php.
flattenConfigArray | ( | $ | field, |
&$ | arr, | ||
$ | prefix = '' |
||
) |
Flattens a configuration array into a normal key-value list so that it is ready to write to a config file.
array | $field | Associative array of configuration options. |
array | &$arr | Output parameter . The flattened array that is output. |
string | $prefix | A string prefix for the keys. |
Definition at line 258 of file builder.php.
& getField | ( | $ | name | ) |
Definition at line 337 of file builder.php.
getParameter | ( | $ | fieldname, |
$ | paramname | ||
) |
Definition at line 342 of file builder.php.
& keys | ( | ) |
Returns a reference to the key fields of this table. If the table has
Definition at line 69 of file builder.php.
removeField | ( | $ | name | ) |
Definition at line 329 of file builder.php.
removeFieldFromDB | ( | $ | field | ) |
Removes a field from the table.
array | Field definition. |
Definition at line 204 of file builder.php.
save | ( | ) |
Saves the table to the database and writes the configuration files.
Definition at line 86 of file builder.php.
setParameter | ( | $ | fieldname, |
$ | paramname, | ||
$ | paramvalue | ||
) |
Definition at line 358 of file builder.php.
update | ( | ) |
Updates the database table schema and config files to match the state of the table object.
Definition at line 132 of file builder.php.
writeConfigFiles | ( | $ | params = array() | ) |
Writes the configuration files (e.g. fields.ini file) for the table.
array | $params | Associative array of parameters |
array | $params,[fields] | An optional array of field definitions |
Definition at line 219 of file builder.php.
$fields = array() |
Definition at line 42 of file builder.php.
string $name |
Definition at line 40 of file builder.php.
$table |
Definition at line 35 of file builder.php.