[WORKING] mosDBTable->bind

Last reviewed: Not reviewed


Copy the contents of an array into the database table object.  This function may be overloaded/supplemented by the child class as required.

The table object is not saved; use mosDBTable->store for that.  This function matches fields in the array with attributes of the same name in the table object. If a field exists in the array but does not match an attribute in the table object then it is ignored. If an attribute exists in the table object but does not match an array field then it will be ignored. Table object attributes with names beginning with an underscore character are always ignored.

Returns true if successful; false otherwise.  If false then the error message can be retrieved using the mosDBTable->getError function.


boolean bind ( array $array [, string $ignore ] )

is the array whose contents are to be bound to the database table object.
is a prefix string. An array entry will bind to a table object attribute only if the field name with the prefix string prepended to it also exists. This parameter is optional and if omitted will default to an empty string.


Example: This example uses the myTable class defined on the mosDBTable class overview page.

global $database;
// Declare an instance of the myTable class.
$row = new myTable( $database );
// Load record with primary key $id.
$row->load( $id );
// Update the title field in the database object.
if (!$row->bind( $_POST, 'title' )) {
  mosErrorAlert( $row->getError() );
// Save the updated record back to the database.
if (!$row->store()) {
  mosErrorAlert( $row->getError() );

Please report any errors on this page to the Developer Documentation Forum.

Last Updated ( Monday, 25 December 2006 )