Re: [PHP-DB] Question on the use of where statements

2004-12-01 Thread Stuart Felenstein
Sorry ..hit the wrong button
--- Stuart Felenstein [EMAIL PROTECTED] wrote:

 I posted this over on mysql list. Not trying to be
 redundant, but would like to get some feedback.
 
 Basically I'm wondering.
 I am creating a search form , dynamic query, that
 could potentially have in the area of 40+ where
 statements.
 
 i.e.   1- where x = y and
 2- cat = blue  and
 3- round = 1045...etc.  

Is there such a thing as where overload.  More
correctly too big of a sql statement.  I'm running on
a shared web host currently.  It's a decent machine,
but not a clustered itanium with load balancing.  

Interested in feedback.

Stuart

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



RE: [PHP-DB] Question on the use of where statements

2004-12-01 Thread Bastien Koert
so...best to build the statement dynamically and execute it once only if the 
input box has a value in it...

$sql = select * from table where 1 ;
if (isset($_POST['field1'])){ $sql .=  and column1 = '.$_POST['field1']. 
';
...
if (isset($_POST['fieldN'])){ $sql .=  and columnN = '.$_POST['fieldN']. 
';

$result = mysql_query($sql);
...
bastien
From: Stuart Felenstein [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Question on the use of where statements
Date: Wed, 1 Dec 2004 07:28:24 -0800 (PST)
I posted this over on mysql list. Not trying to be
redundant, but would like to get some feedback.
Basically I'm wondering.
I am creating a search form , dynamic query, that
could potentially have in the area of 40+ where
statements.
i.3.   1- where x = y and
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Question on the use of where statements

2004-12-01 Thread Stuart Felenstein
--- Bastien Koert [EMAIL PROTECTED] wrote:

 so...best to build the statement dynamically and
 execute it once only if the 
 input box has a value in it...
 

And that is the way I'm building it.  Just thinking
about the scenario that somone actually chooses 75% of
the options - would that potentially make a huge hit
on the system.

Stuart

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



RE: [PHP-DB] Question on the use of where statements

2004-12-01 Thread Gryffyn, Trevor
I think you may hit the limit on the number of characters in the SELECT
statement before you hit the max number of WHERE items.

It's a good question though.Try doing a worst case scenario (pick
all the options, enter data that's the max character length for each
item, etc).  Either through your form or typing it all manually.  The
worst that'll happen is it'll say Sorry.. Too many characters or Too
many WHERE items or something.

Also, check the documentation for the database system you're using
(MySQL or whatever) and see if it says anything under the WHERE clause
or max length of SELECT statement.

If you find anything interesting, let us know.  Sorry couldn't give you
a better answer.

-TG

 -Original Message-
 From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, December 01, 2004 10:56 AM
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Question on the use of where statements
 
 
 --- Bastien Koert [EMAIL PROTECTED] wrote:
 
  so...best to build the statement dynamically and
  execute it once only if the 
  input box has a value in it...
  
 
 And that is the way I'm building it.  Just thinking
 about the scenario that somone actually chooses 75% of
 the options - would that potentially make a huge hit
 on the system.
 
 Stuart

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



RE: [PHP-DB] Question on the use of where statements

2004-12-01 Thread Bastien Koert
actually that would reduce it since a fewwer number of rows would 
potentially match the query...ensure that there is a composite index on a 
good selection of the columns to mkae the query quicker

bastien
From: Stuart Felenstein [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Question on the use of where statements
Date: Wed, 1 Dec 2004 07:55:35 -0800 (PST)
--- Bastien Koert [EMAIL PROTECTED] wrote:
 so...best to build the statement dynamically and
 execute it once only if the
 input box has a value in it...

And that is the way I'm building it.  Just thinking
about the scenario that somone actually chooses 75% of
the options - would that potentially make a huge hit
on the system.
Stuart
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php