Abstract superclass of a data source.
DBLIB uses generalized database model and this is it's main class. The model allows you to use DBLIB with different data sources. The most common one is a SQL database, but you may also wish to use LDAP, files, or even your own query types (see DBLArrayQuery for example).
The datasource here does not mean only source - it also provides ways to modify/create/delete records.
Please note, that DBLQuery descendant is responsible for properly converting (escaping) all values it is passed. So if your application uses DBLQuery to access database, it is safe!
It is quite hard to provide uniform interface to such different data bases. So rather the methods defined here are for the greatest functionality the DBLQuery descendant may provide. They may not be implemented all.
I suppose the application using DBLIB will know what database it uses and so what functionality the database can provide. If the database cannot do record ordering, the application cannot use order in filters. If it cannot do record range limiting, the application cannot use paged indexes, etc. Notes on required DBLQuery functionality can be found in DBLView method description.
However, DBLQuery descendants MAY provide some of the functionality missing in the DB engine, it's up to them.
Located in /DBLQuery.php (line 39)
Class | Description |
---|---|
DBLArrayQuery | Query returning values from a (static) array as rows. |
DBLSQLQuery | DBLQuery (abstract) subclass implementing routines common for all SQL databases. |
Constructor.
Add condition to 'filter records'.
The conditions are used in three functions: - In the search() method, to limit which rows will be returned. - In tthe modifyRecord() method to designate which records will be modified. - In tthe deleteRecord() method to designate which records will be deleted.
This method is rather general. It is used by the DBLView class to implement filters, so it should be implemented by the DBLQuery class you use, if you wish to use the filters. There MAY be class specific methods to add DB specific conditions.
The operators that should be supported: <, >, =, !=, <>, <=, >=, wild (* and ? wildcards)
Adds new record.
This is the method if you want to create a new record with DBLQuery. First you shoult setup values (by the addValue method), then call addRecord to create the record.
NOTE: This method does not clear the conditions/values set!
Adds value to be used to modify/create record.
Clear all set conditions.
Clears all set values.
Deletes record(s).
This method deletes all records that match set conditions. You will usually want to set the condition to match primary key of the modified record ;-)
DBLIB does not use this method directly, it is here just for the function set to be complete.
NOTE: This method does not clear the conditions set!
Format datetime for the database backend.
This is used by the DBLIB to format the date to pass to the addValue/addCondition method.
Return default date/time/datetime in the DB notation
Return whether the date/datetime is "empty"
Modifies existing record(s).
This method modifies existing records in the data source. The records are specified by set conditions (addCondition). You will usually want to set the condition to match primary key of the modified record ;-)
Function modifies all fields of the record, which were added by addValue(). The other fields should not be touched (!).
NOTE: This method does not clear the conditions/values set!
Gets next record from a result set.
After the search has been initiated by caling the search() method, you can get the record(s) from the search by this method.
Parse date or datetime from the database backend format to variables.
Dates are returned in human form - years in AD, months 1..12, days 1..31. When only date is passed in (without time), hour, minute and second are set to 0.
Reset query.
This method 'resets' query to the state as if it was just created. Removes all set conditions, values, orders, limits (AND!) sources. so you have to call setSource after this!
Starts retrieving data from the data source.
This method initiates record search. After the search is initiated, data row can be get by calling the nextRecord() method.
Set fields to be returned from search()/nextRecord() methods.
This method may be used to limit/specify which fields of the record will be returned. Its format is class dependent. By default, all applicable fields should be returned.
If you wish to use the lookup fields, the query you use should implement some kind of field aliasing (so that the record the query returns contains id and text fields). The fields specification is the place where field aliasing should be specified.
Limits range of records to be returned from search()/nextRecord() methods.
This method sets range of records to return. It is used by the DBLView class to implement record index paging. If the DBLQuery descendant does not support record ranges, you cannot use paging (set DBLView::pageLength to 0).
Set query order.
This method sets order of the records returned by the search() (and then nextRecord()) methods. If record ordering is not implemented by DBLQuery descendant, then you may not use the _order field in the filter form (see DBLView::filter()).
Set new source (sets the srcDef property).
Documentation generated on Mon, 6 Sep 2004 21:57:17 +0200 by phpDocumentor 1.2.3