This is the superclass for all RSDTable classes created for a specific table.
Located in /code/framework/RSDEngine/RSDTable.php (line 65)
PEAR | --RSDTable
Constructor that calls the base class constructor PEAR().
Returns whether the currently logged in user has the permission to perform an insert operation.
Must be overwritten. Should return true if no unique constraints would be violated by using the array of assignments passed as argument for a INSERT or a UPDATE operation. Otherwise false should be returned.
Returns an integer representing the number of records that matched the conditions passed as first argument.
Deletes records from this table.
Whether records that matched the conditions passed as first argument exist.
Returns a WHERE clause generated from the array passed as argument.
1 $table->generateWhereClause(
2 array(
3 "f_title" => "Peters's",
4 "f_date" => new RSDColumnValue("NOW()", "!"),
5 "f_file" => RSDColumnValue("test.txt", "&"),
6 "f_description" => RSDColumnValue("This is a test.", "?"),
7 "f_data" => RSDColumnValue("test", "%")
8 )
9 );
The element key represents the column name. The value that should be 'assigned' to the column can either be specified directly as the element value or as an instance of RSDColumnValue. Note that "f_title" => "My Title" is equal to "f_title" => RSDColumnValue('My Title', '?') because '?' is the default. The column name, the column value and the 'prepareString' ('!','&','?' or '%') are passed to the method $this->_generateAssignment. The example above would result in the following where clause (if oracle is used; ' is escaped with ''):
1 WHERE
2 f_title='Peters''s'
3 AND
4 f_date=NOW()
5 AND
6 f_file='The contents of the file test.txt with quotes('') escaped.'
7 AND
8 f_data LIKE '%test%'
If you wish to connect the conditions differently than by AND, use the following format:
1 $table->generateWhereClause(
2 array(
3 array(
4 "f_title" => "Peters's",
5 "f_date" => RSDColumnValue("NOW()", "!"),
6 "f_file" => RSDColumnValue("test.txt", "&"),
7 "f_description" => RSDColumnValue("This is a test.", "?"),
8 "f_data" => RSDColumnValue("test", "%")
9 ),
10 "%s1 AND %s2 AND (%s3 OR %s4 OR %s5)"
11 )
12 );
Note that the the conditions-array from the previous example is now itself placed in an array (as the first element. The second element is a string that defines the format. %s1 is replaced with the first condition, %s2 with the second condition, and so on... If $conditions is a string this string will be returned without modifications. If $conditions is an array and has has a length of 0 or is (===) the boolean value false, an empty string will be returned. NOTE: this might be dangerous if the where clause is used in a DELETE or UPDATE statement! If $conditions is not an array and not a string the string "WHERE 1=2" will be returned. This is because if it's not a string nor an array something must have gone wrong; and in in that case we do not want to risk to cause unexpected results. Returns an associative Array with all records from the specified select matching the conditions passed as first arguement.
The select-method to invoke can be specified by the second argument. Valid values are the names of all methods stating with "selectIncluding..." and "select". The default is to invoke the method select.
Fetch all the rows returned from a query.
This method is just like the method DB::getAll. But it adds the possibility to limit the result by specifying the arguments $from and $to.
Returns the value of what ever was specified as column value.
If an instance of RSDColumnValue was passed as argument the property value will be returned; if a string was passed, this string will be returned.
Returns the name of the method that checks if a value is valid for the column supplied as argument.
Returns an sql statement that can be used in a select query to retrieve a literal representation of this record.
This method should be overwritten in the child class!
Returns just one field of one record from this table.
This method uses getRow to get one record from this table. array_shift is used to extract the first column.
Returns just one record from this table.
Returns an array for use with a SMARTY {html_options} statement.
In this example getSmartyHTMLOptionsArray would return the array $cust_options.
1 <select name=customer_id>
2 {html_options options=$cust_options selected=$customer_id}
3 </select>
Inserts a record into the table.
The argument $inserts contains a variable number of values assigned to fields. The key is always the clumn name. The value can be just a string as it is the case for f_title in the following example. But it is as well possible to specify the value as an instance of RSDColumnValue containing two properties. These properties are set by the contructor of RSDColumnValue. The first constructor argument specifies the value, the second specifies the prepare string (i.e. the way this value should be treated). You can set the second field to the string '!' as it is the case for f_date to prevent the value to be quoted. You can as well set it to '&' which means the value is a filename and its contents should be inserted. Note that the assignment for f_title is equivalent to the assignment for f_description because '?' is assumed if the value is not specified as an instance of RSDColumnValue.
1 $table->insert(
2 array(
3 "f_title" => "My Title",
4 "f_date" => new RSDColumnValue("NOW()", "!"),
5 "f_file" => new RSDColumnValue("test.text", "&"),
6 "f_description" => new RSDColumnValue("This is a test.", "?")
7 )
8 );
Returns true if the value passed as second argument is valid for the column passed as first argument.
Returns true if such a primary key exists in the specified table otherwise a new PEAR_Error.
Transforms an array of records to an array for use with a SMARTY {html_options} statement.
This method is static! Be aware of the difference to getSmartyHTMLOptionsArray.
Returns a two-demensional Array of records. One record is hold by one array.
All arguments are optional.
This method should be overwritten in a child class. It should perform a join over all related tables.
This method should be overwritten in a child class. It should perform a join over all tables that referenced by a foreign key define in this table.
Updates records in this table.
The argument $updates contains a variable number of values assigned to fields. The key is always the column name. The value can be just a string as it is the case for f_title in the following example. But it is as well possible to specify the value as an instance of RSDColumnValue containing two properties. These properties are set by the contructor of RSDColumnValue. The first constructor argument specifies the value, the second specifies the prepare string (i.e. the way this value should be treated). You can set the second field to the string '!' as it is the case for f_date to prevent the value to be quoted. You can as well set it to '&' which means the value is a filename and its contents should be inserted. Note that the assignment for f_title is equivalent to the assignment for f_description because '?' is assumed if the value is not specified as an instance of RSDColumnValue.
1 $table->update(
2 array(
3 "f_title" => "My Title",
4 "f_date" => new RSDColumnValue("NOW()", "!"),
5 "f_file" => new RSDColumnValue("test.text", "&"),
6 "f_description" => new RSDColumnValue("This is a test.", "?")
7 )
8 );
Generates an SQL-assignment of a value to a column usable in a where clause.
1 return "$column LIKE " . $this->db->quote("%$value%");
Documentation generated on Mon, 8 Dec 2003 13:13:02 +0100 by phpDocumentor 1.2.3