Tripal
|
Public Member Functions | |
__construct ($table_name, $record_id=NULL) | |
getID () | |
getTable () | |
getSchema () | |
save () | |
insert () | |
update () | |
delete () | |
setValues ($values) | |
getValues () | |
setValue ($column_name, $value) | |
getValue ($column_name) | |
find () | |
Protected Attributes | |
$table_name = '' | |
$schema = [] | |
$values = [] | |
$required_cols = [] | |
$missing_required_col = [] | |
$record_id = NULL | |
$pkey = '' | |
$column_names = [] | |
Provide a class for basic querying of Chado.
Specifically tihs class provides select, insert, update and delete.
Eventually this class is meants to replace the existing chado_select_record(), chado_insert_record(), chado_update_record() and chado_delete_record() API functions to create a cleaner, more maintainable and more easily tested interface to querying Chado.
Basic Usage:
ChadoRecord::__construct | ( | $table_name, | |
$record_id = NULL |
|||
) |
The ChadoRecord constructor
string | $table_name | The name of the table that the record belongs to. |
string | $record_id | An optional record ID if this record is already present in Chado. |
ChadoRecord::delete | ( | ) |
Deletes the record that matches the given values.
A record ID must be part of the current values.
Exception |
ChadoRecord::find | ( | ) |
Uses the current values given to this object to find a record.
Use the setValues function first to set values for searching, then call this function to find matching record. The values provided to the setValues function must uniquely identify a record.
Support options from chado_select_record: skip_validation, has_record, return_sql, case_insensitive_columns, regex_columns, order_by, is_duplicate, pager, limit, offset.
Support following the foreign key
Support complex filtering (e.g. fmin > 50)
Support multiple records being returned?
Exception |
ChadoRecord::getID | ( | ) |
Retrieves the record ID.
ChadoRecord::getSchema | ( | ) |
Retrieves the table schema.
ChadoRecord::getTable | ( | ) |
Retrieves the table name.
ChadoRecord::getValue | ( | $column_name | ) |
Returns the value of a specific column.
string | $column_name | The name of a column from the table from which to retrieve the value. |
ChadoRecord::getValues | ( | ) |
ChadoRecord::insert | ( | ) |
Inserts the values of this object as a new record.
Support options from chado_insert_record: return_record.
check for violation of unique constraint.
Exception |
ChadoRecord::save | ( | ) |
Performs either an update or insert into the table using the values.
If the record already exists it will be updated. If the record does not exist it will be inserted. This function adds a bit more overhead by checking for the existence of the record and performing the appropriate action. You can save time by using the insert or update functions directly if you only need to do one of those actions specifically.
Exception |
ChadoRecord::setValue | ( | $column_name, | |
$value | |||
) |
Sets the value for a specific column.
Support options from chado_insert_record: skip_validation.
Validate the types match what is expected based on the schema.
Set default values for columns not in this array?
Support foreign key relationships: lookup the key.
Support value = [a, b, c] for IN select statements?
string | $column_name | The name of the column to which the value should be set. |
$value | The value to set. |
ChadoRecord::setValues | ( | $values | ) |
A general-purpose setter function to set the column values for the record.
This function should be used prior to insert or update of a record. For an update, be sure to include the record ID in the list of values passed to the function.
Support options from chado_insert_record: skip_validation.
Validate the types match what is expected based on the schema.
Set default values for columns not in this array?
Support foreign key relationships: lookup the key.
Support value = [a, b, c] for IN select statements?
array | $values | An associative array where the keys are the table column names and the values are the record values for each column. |
Exception |
ChadoRecord::update | ( | ) |
Updates the values of this object as a new record.
set defaults for columns not already set in values.
Support options from chado_update_record: return_record.
check for violation of unique constraint.
if record_id not set then try finding it.
Exception |