PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB_DataObject » Bug #4472

Added New Features for setFrom and _buildConditions, find for cross databases

Details

Request #4472Added New Features for setFrom and _buildConditions, find for cross databases
Submitted2005-05-30 06:05 UTC
Fromdanielr at electroteque dot org
StatusWont fix
PackageDB_DataObject
PHP Version5.0.3
OSN/A
Roadmaps(Not assigned)

Comments

[2005-05-30 06:05 UTC] danielr at electroteque dot org

Description:
------------
I have finally seperated these three tweaks into a
DataObject subclass that my DO's extend. It would be
great to have these available. I am going to link to a
phps file as these are not differable because they arent
in the cvs file.

www.electroteque.org/pear/DataObject2.phps

The issues that have arisen that made me make these
changes were, when using setFrom with post data say for
a search filter, setFrom was not ignoring empty post
variables therefore building a huge search query
obviouslly with nullable fields so was not filtering
properly.

whereAdd adds an argument to change the logic of the
condition to AND/OR.

_build_condition adds two options, one is a global AND/
OR logic setting defined by a setLogic method. There is
also a customisable condFieldname method to be a
condition setter for fields. Example

/**
* Ticket Number DataObject Condition setter
*/

function setCondTicket_number($key,$string) {
$this->whereAdd("$key LIKE '%".$this-
>escape($string)."%'",$this->_searchLogic);
}

I added an extra change to find, because when using
cross database DO's , it was either connecting to either
one of the databases and therefore not finding the
table, i added a feature to include the database name
into the query however, I have been told this is not a
portable option ? Please advice on another way to do
this if possible.

[2005-06-04 02:34 UTC] danielr at electroteque dot org

Hmm, please advise then how I could build a search query
from an advanced form search filter ? Theoretically as
it stands with setFrom, it adds all the extra fields to
the where query for some reason :|

I've added extra functionality to add a condition
setter, so instead of doing where field='' we can do
where field like '%%' or where match(field) against (''
IN BOOLEAN MODE) etc ... The logic is handy so in my
form I can select if its an AND/OR search which defaults
to AND and there is no option to change this without
extra bulky code.

How do u usually do this then ?

[2005-06-04 02:48 UTC] danielr at electroteque dot org

Ok its a little unclear, as my (hack) works for me :) So

function buildSearchQuery($array)
{
......
}

loop through array remove empty values then send that to
setFrom ?? I suppose that would work to and i'd put it
in my base class.

What about the setCond setter useful or useless ?? :)