MDB_QueryTool provides the following methods:
Join the given tables, using the column names, to find out how to join the tables; i.e., if table1 has a column named "table2_id", this method will join "WHERE table1.table2_id=table2.id". All joins made here are only concatenated via AND.
Return a PEAR::DB object
Pass an existing PEAR::DB object to MDB_QueryTool
Get the data of a single entry. If the second parameter is only one column, the result will be returned directly, not as an array!
Same as get(), but for all the elements in the $ids array.
Get all the entries from the db.
This method only returns one column, so the result will be a one dimensional array. This does also mean that using setSelect() should be set to *one* column, the one you want to have returned. A common use case for this could be:
$table->setSelect('id'); $ids = $table->getCol(); //OR $ids = $table->getCol('id');
Get the number of entries.
return an empty element where all the array elements do already exist corresponding to the columns in the DB
Render the current query and return it as a string.
Save data, calls either update() or add(). If the primaryCol is given in the data this method knows that the data passed to it are meant to be updated (call update()), otherwise it will call the method add(). If you don't like this behaviour simply stick with the methods add() and update() and ignore this one here. This method is very useful when you have validation checks that have to be done for both adding and updating, then you can simply overwrite this method and do the checks in here, and both cases will be validated first.
Update the member data of a data set.
Add a new member in the db.
Adds multiple new members in the db.
Removes a member from the db. data is the value of the column that shall be removed (integer/string); if an array is used, it must contain multiple columns that shall be matched (in this case, the second parameter will be ignored); $whereCol: the column to match the data against, only if data is not an array
Empty a table.
Remove the datasets with the given ids. If colName is set, it is used as the primary key column name.
removePrimary($ids, $colName, $atLeastOneObject)
Removes a member from the db and calls the remove() methods of the given objects so all rows in another table that refer to this table are erased too.
Set the limits for the following query.
Get the limits for the following query.
Sets the where condition which is used for the current instance.
Gets the where condition which is used for the current instance.
Adds a string to the where clause. The default condition is AND.
addWhereSearch($column, $stringToSearch, $condition)
Add a where-like clause which works like a search for the given string; i.e. calling it like this:
$this->addWhereSearch('name', 'otto hans')
UPPER(name) LIKE "%OTTO%HANS%"
Sets the order condition which is used for the current instance.
Gets the order condition which is used for the current instance.
Adds an order parameter to the query.
Sets the having condition which is used for the current instance.
Gets the having condition which is used for the current instance.
Adds an having parameter to the query.
setJoin($table, $where, $joinType)
Sets the join condition which is used for the current instance.
Sets a left join on $this->table.
addLeftJoin($table, $where, $type)
Adds a left join to the query.
Sets a right join on $this->table.
Gets the join-condition.
addJoin($table, $where, $type)
adds a table and a where clause that shall be used for the join instead of calling
setJoin(array(table1, table2), '<where clause1> AND <where clause2>');
setJoin(table1,'<where clause1>'); addJoin(table2,'<where clause2>');
Sets the table this class is currently working on.
Gets the table this class is currently working on.
Sets the group-by condition.
Gets the group-by condition.
Limit the result to return only the columns given in what.
Add a string to the select-part of the query and connects it to an existing string using the connectString, which by default is a comma. ("SELECT xxx FROM..." xxx is the select-part of a query)
Gets the select-part of the query.
Exclude some columns from the resultset.
Gets the columns excluded from the resultset.
Reset all the set* settings, with no parameter given it resets them all.
Set mode the class shall work in. The 'raw' mode does not quote the data before building the query
Get the given option.
override this method and i.e. print the queryString to see the final query.
Gets the short name for a table.
Execute a query (the current query is executed when query is null.
Write events to the logfile. It does some additional work, like time measuring etc. to see some additional info.
Return the chosen result type
Format the result to be indexed by key. NOTE: be careful, when using this you should be aware, that if you use an index which's value appears multiple times you may loose data since a key can't exist multiple times! The result for a result to be indexed by a key(=columnName) (i.e. 'relationtoMe') which's values are 'brother' and 'sister' or alike normally returns this:
$res['brother'] = array('name' => 'xxx'); $res['sister'] = array('name' => 'xxx');
Gets the index.
Choose the type of the returned result ('array', 'object', 'none')
Set both callbacks.
Set the error log callback.
Set the error set callback.