Re: Help: Database Search

From: Date: Wed, 10 Nov 2004 23:55:54 +0000
Subject: Re: Help: Database Search
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-201687@lists.php.net to get a copy of this message
On Wednesday 10 November 2004 15:37, Stuart Felenstein wrote: > --- Jason Wong <php-general@gremlins.biz> wrote: > > Why not build your sql query according to whether or > > not whatever you want is > > selected or not. That way debugging is easier as > > you won't be looking at > > queries that contain redundant "... AND 0 ...". > > Jason, How would I do that ? Care to share a short > exmaple ? A simplistic pseudo-code version: $sql = "SELECT <blah> WHERE 1"; if ($something = "selected") { $sql .= "AND something"; } ... ... $sql .= "... rest of query"; Anyway, someone has already posted a more detailed example. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* Hmm... Which would do a better job at driving physicists crazy? Travel faster than light, or a floating-point boolean value? -- Michael Mol */

« previous php.general (#201687) next »