Re: DB_DataObjects and generating search filters

From: Date: Thu, 21 Apr 2005 03:11:00 +0000
Subject: Re: DB_DataObjects and generating search filters
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-18848@lists.php.net to get a copy of this message
> > Are you asking if you would need to check if each post field is set? I > wouldn't think so. If you wrapped something a bit like the code I > provided in a loop (for each element of $_POST) then I think it would > work the way you expected. Even if a a given $_POST variable was > empty, then it would end up producing the SQL "field_name LIKE '%%'", > which means, 'like anything'. If you didn't want that (it is a waste > of processing after all), then you just put a simple if statement > inside your loop. I don't see any problem with using this in general > code. I went one step further, because of this limitation, I hope nobody minds i will send a diff but imade a change to the _build_condition method, i have added an option to a global logic when itgenerates the whereAdd for each field. Maybe this should happen in whereadd itself, a new var_searchLogin which defaults to AND and a setter method setLogic to set the logic variable to OR ifyou want :) Ok maybe this isnt a good idea, but i am porting a search system from an old way i didit and i had a pulldown to select an AND or OR condition. I cant see why this couldnt happen in the internals as i'd be duplicating the same code all the time,I do also have a prob with toArray as i'd want the primary keys as the option values of selectmenus so had to make a function to preformat that :| Unless there is already a way ? I do however need to format conditions for a few text fields to use LIKE instead of =, i have yet tofind out if it overwrites it after. Was wondering if there could be special setter methods for whereclauses only as it would screw with inserts and updates :)

« previous php.pear.general (#18848) next »