NYCPHP Meetup

NYPHP.org

[nycphp-talk] Partial Name Lookup Function in PEAR

Phil Duffy phil at bearingasset.com
Sun Sep 4 10:44:59 EDT 2005


Lee,

 

This is the PEAR-based solution to the question I posed earlier.

 

    $personList = & new DataObjects_Person();

    $lastNamePattern = $input->person->last_name;

    $lastNamePattern = addslashes($lastNamePattern) . '%';

    $personList->whereAdd("last_name LIKE '$lastNamePattern'");

    $personList->orderBy('last_name');

    $result = $personList->find();

 

Many thanks for your prompt, excellent suggestion.  It started me on the
right path and allowed me to pose a specific question to the Seagull
community, which provided an insight.

 

Phil

 

 

  _____  

From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of leeeyerman at aol.com
Sent: Wednesday, August 31, 2005 8:19 PM
To: talk at lists.nyphp.org
Subject: Re: [nycphp-talk] Partial Name Lookup Function in PEAR

 

 I do not know about PEAR but if you are just trying to look up a first or
last name (or anything other name/text) using only a partial piece of
information the LIKE command is best.

 

SELECT "column" FROM "table" WHERE "column_name" LIKE [PATTERN] 

 

ie.

 

SELECT * FROM pics WHERE pic_name LIKE '%ANG%'

 

This would return all pic_name where ANG is contained in the string.

 

http://www.1keydata.com/sql/sqllike.html

http://www.techonthenet.com/sql/like.php 

 

 

 
-----Original Message-----
From: Phil Duffy <phil at bearingasset.com>
To: 'NYPHP Talk' <talk at lists.nyphp.org>
Sent: Wed, 31 Aug 2005 21:05:48 -0400
Subject: [nycphp-talk] Partial Name Lookup Function in PEAR

Does PEAR offer a partial name lookup function?  What is the best way to do
a partial name lookup in a database-independent manner?  If I must drop back
to hard-coded MySQL calls, is the LOCATE() function the appropriate one to
use in this situation?

Any responses will be appreciated, including advice to direct these
questions to another list.

Phil Duffy

_______________________________________________

New York PHP Talk Mailing List

AMP Technology

Supporting Apache, MySQL and PHP

http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20050904/70cb52e7/attachment.html>


More information about the talk mailing list