Class: GALTable
Source Location: /libbase/table.inc.php
Represents a table inside a database.
Author(s):
Implements interfaces:
|
|
|
Class Details
Class Variables
Class Methods
constructor __construct [line 758]
destructor __destruct [line 812]
Destructs all rows stored in $rows. It makes use of recurse_rows().
method buildResult [line 1335]
method compareExpression [line 1328]
void compareExpression(
string
$field, string
$operator, string
$value)
|
|
Factory for GALExpressionCompare objects.
Parameters:
method containsKeyFields [line 948]
bool containsKeyFields(
array
$fields)
|
|
Checks if the specified fields contains a field that belongs to the primary key.
Tags:
Parameters:
method count [line 1160]
int count(
[GALExpression
$expr = true], [string
$additional = ""])
|
|
Count rows that match the given GALExpression. This method calls rawLoad() with "WHERE ".$expr->__toString()." $additional"
as argument. Because PHP 5 doesn't support objects as default argument, TRUE is default instead of GALExpressionTRUE.
Tags:
Parameters:
method countFields [line 1420]
method delete [line 1302]
Deletes the row identified by $key from the database. This method deletes a single row from the database and marks it as deleted in $rows. The $key parameter must contain all fields of the primary key and no other fields.
Tags:
Parameters:
method extendedCount [line 1188]
int extendedCount(
string
$join, GALExpression
$expr, [mixed
$order = ""], [string
$limit = ""], [string
$additional = ""])
|
|
Template for complex count queries. This method allows to build a more complex SQL query from the submitted pieces. This method is introduced because in many cases JOIN statements, expressions, ORDER statements and LIMIT statements are created in different places. This method provides a shortcut to put them all together. Additionally, this method allows to introduce new ways to specify such a statement without changing much code - just redefine it in descending classes or change it in this place. Theoretically the ORDER statement is senseless, but it remains to be compatible with extendedLoad() regarding the parameters.
Tags:
Parameters:
method extendedLoad [line 1118]
Template for complex queries. This method allows to build a more complex SQL query from the submitted pieces. This method is introduced because in many cases JOIN statements, expressions, ORDER statements and LIMIT statements are created in different places. This method provides a shortcut to put them all together. Additionally, this method allows to introduce new ways to specify such a statement without changing much code - just redefine it in descending classes or change it in this place.
Tags:
Parameters:
method fullKey [line 978]
bool fullKey(
array
$keys)
|
|
Checks if the specified fields in $keys are the full primary key.
Tags:
Parameters:
method getFields [line 1410]
Returns all fields contained in this result.
Tags:
Implementation of:
- GALDesc::getFields()
- Returns all fields contained in a result.
method getFlags [line 1364]
method getIfRegistered [line 895]
Return the row with the submitted primary key values, if it has been registered before.
Tags:
Parameters:
method getLength [line 1388]
method getName [line 787]
Returns this table's name.
method getParent [line 1441]
Returns a reference to this table. A GALTable is a top level element, so this method returns a reference to itself.
Tags:
Implementation of:
- GALDesc::getParent()
- Return the top level parent of an entity.
method getPrimaryKey [line 1008]
Returns the primary key of this table.
Tags:
method getResultFactory [line 1342]
Returns the factory to construct results.
method getRowFactory [line 1350]
Returns the factory to construct rows.
method getTable [line 1400]
string getTable(
string
$field)
|
|
Gets the name of the table the given field is contained in. Wrapper for GALResult::getTable().
Tags:
Implementation of:
- GALDesc::getTable()
- Gets the name of the table the given field is contained in.
Parameters:
method getType [line 1376]
method insert [line 1227]
Inserts a row into this table. unfortunately this method cannot return the inserted data as row object, because data might be changed (default values, AUTO_INCREMENT), and keys are possibly created by an AUTO_INCREMENT field, so in some cases it is difficult to reconstruct the inserted data. >:-( (multiple AUTO_INCREMENTs and so on) To make things easier though, this function returns the value of mysql_insert_id().
Tags:
Parameters:
method insertMultiple [line 1250]
void insertMultiple(
array
$fields, array
$data)
|
|
Inserts multiple rows into the database. Example how to insert two rows into the table `users` wich contains the fields `name`, `ID`, `email`: $table = $db->table('users');
$fields = array('name', 'ID', 'email');
$values = array(
array('Kurt', 4, 'kurt@example.com'),
array('Ernst', 5, 'ernst@example.com')
);
Field and value are mapped together by their position in the arrays.
Tags:
Parameters:
method isField [line 1431]
bool isField(
string
$field)
|
|
Checks if the given field is contained in a result. Wrapper for GALResult::isField().
Tags:
Implementation of:
- GALDesc::isField()
- Checks if the given field is contained in a result.
Parameters:
method load [line 1092]
Load rows that match the given GALExpression. This method calls rawQuery() with "WHERE ".$expr->__toString()." $additional"
as argument. Because PHP 5 doesn't support objects as default argument, TRUE is default instead of GALExpressionTRUE.
Tags:
Parameters:
method rawCount [line 1141]
int rawCount(
[string
$what = ""])
|
|
Counts rows from this table. This method submits "SELECT COUNT(`$table`.*) AS `count` FROM `$table` $what" to the database, where $table is the name of this table. Note that there's no filtering of $what, so be careful! This method allows full flexibility in the selection of what is counted, e.g. complex joins, SQL functions and so on.
Tags:
Parameters:
method rawLoad [line 1072]
Loads rows from this table. This method submits "SELECT `$table`.* FROM `$table` $what" to the database, where $table is the name of this table. Note that there's no filtering of $what, so be careful! This method allows full flexibility in the selection of what is to be fetched, e.g. complex joins, SQL functions and so on. It is final to make sure that all fetched items are registered: GALTableIterator::fetch() is final, too; therefore it is impossible to circumvent the registration
Tags:
Parameters:
method register [line 832]
Registers the specified row or returns an already registered row. This method's task is to make sure that for one row in the database only one GALTableRow object exists. Therefor after constructing a GALTableRow in GALTableIterator::fetch(), it is registered here. This method checks if a row with the same primary key values was registered before. If such a row doesn't exist, this method creates a new entry in $rows and returns the $row parameter. If such a row exists, the row registered before is returned and the row passed in $row is destroyed. If the row in $rows is marked as deleted (this happens if a row is deleted from the database in delete(), but the result of a query is still existing), the submitted row object is destroyed and the destroyed row is returned.
Tags:
Parameters:
method registered [line 877]
Checks if the specified row is already registered.
Tags:
method row [line 1198]
Fetches a row matching the given key from the database.
Tags:
Parameters:
method setRegistered [line 924]
void setRegistered(
array
&$keys, mixed
$value)
|
|
Set the entry in $rows specified by &$keys to the specified value. This is for internal purposes and doesn't perform any consistency checks. You can easily mangle the $rows property by using this function!
Tags:
Parameters:
method stripKeys [line 992]
void stripKeys(
array
&$data)
|
|
Removes all fields from the submitted data which belong to the primary key.
Tags:
Parameters:
method unregister [line 859]
Removes a registered row. This method is used to remove a row from $rows. If you want to replace a row, you have to delete it, and before inserting the new row you have to unregister the new row because otherwise registering the new row would fail due to the old row remaining as marked 'dead'.
Tags:
Parameters:
method updateRow [line 1020]
void updateRow(
array
$keys, array
$data)
|
|
Sets the fields of the specified row to the specified values. This method builds an UPDATE statement and submits it to the database. A row is identified by it's primary key, and changing the fields of the primary key is not supported. If you want to change the primary key, the best way is to delete the row and insert it with the new key.
Parameters:
method validFields [line 963]
bool validFields(
array
$fields)
|
|
Checks if all the field names submitted in $fields are valid.
Tags:
Parameters:
|
|