#native_company# #native_desc#
#native_cta#

So you want to use a database in your site? Page 6

By Jess Castagnetto
on July 30, 2000

In the script above we have two general parsing functions that return a valid
SQL comparison statement, these can be extended to cases in which we want to
allow the use of operators such as: AND, OR, NOT, etc.
In this script, you saw the use of default values for some of the
parsing functions parameters; this allows the invokation of the function
with a variable number of said parameters. You will only need to specify
the defaulted ones if you need to change them.
We will use the form to
search for the keywords “image,reading,creating“, in the title of
articles written by Matias or Mark or Rasmus, with a publication date of 1999
or later. This will generate the following result:
Query Results
Saving your query for debugging purposes
You searched on articles with the words image,reading,creating in the
title; written by Mark Musone OR Mattias Nilsson OR Rasmus Lerdorf published
on or after 1999.

and it found: 3 rows
title author published length
IMAP Mail Reading With PHP3 Mark Musone 19990207 200
Creating your own logfile Mattias Nilsson 19990302 200
Image Creation With PHP Rasmus Lerdorf 19990124 200
The form and the handling script can be modified to allow searching on more
variables, or to search for keywords in the title and/or the body of the
article, or even to retrieve a keyword matched in the body in a context (for example,
get the 2 lines above and below the matching line).
Using a form like this gives control on the information the user can access,
and reduces the number of possible SQL queries. If you type straight SQL, you
can always make a query that can take (for practical purposes) and infinite
amount of time to finish, something you may not want to happen in your site.

1
|
2
|
3
|
4
|
5
|
6
|
7