Re: Help: Database Search

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday 10 November 2004 15:37, Stuart Felenstein wrote:
> --- Jason Wong <php-general@xxxxxxxxxxxx> 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
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux