Re: Wildcard queries via PHP4

From: "Peter" <peterh(at)600ml(dot)com(dot)au>
To: "Jesus Aneiros" <aneiros(at)ucfinfo(dot)ucf(dot)edu(dot)cu>, "PostgreSQL PHP" <pgsql-php(at)postgresql(dot)org>
Subject: Re: Wildcard queries via PHP4
Date: 2001-11-16 05:50:42
Message-ID: 009d01c16e62$a0c0e110$0300000a@600mlPeterPC1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

yes the easiest way is select * from table where LIKE '%$NAME%' for case
sensitive search
or select * from table where ILIKE '%$NAME%' if the you want to do
a case insensitive search
much, much, much faster than regular expression

regards, Peter

----- Original Message -----
From: "Jesus Aneiros" <aneiros(at)ucfinfo(dot)ucf(dot)edu(dot)cu>
To: <beloshapka(at)mnogo(dot)ru>
Cc: <pgsql-php(at)postgresql(dot)org>
Sent: Friday, April 06, 2001 1:28 PM
Subject: Re: [PHP] Wildcard queries via PHP4

> You could try LIKE and %, but I think it is ~* and not *~
>
> Saludos, Jesus.
>
> On Thu, 5 Apr 2001, rickf wrote:
>
> > Hi,
> >
> > I am trying to find the syntax to pass a wildcard query through to
postgres.
> > Basically I just want to use the user input as a substring of the actual
> > query to postgres.
> > It can even be simpler, I realy only need the wildcard at end of the
input
> > string
> >
> > i.e. user inputs Smith in form, I want to pick up Smith & Smithsonian.
> >
> > Right now I have:
> >
> > if ( strlen($NAME) >0):
> > $NAME = addslashes($NAME);
> > $NAME = strtolower($NAME); /
> > $NAME = ucfirst($NAME); file://translation final to Upper 1st
letter
> > rest lower as per db format.
> >
> > $conn = pg_Connect("dbname=damn_db port=5432");
> > if(!$conn) { echo "Error in connecting to DB\n"; exit; }
> > $result = pg_Exec($conn, "SELECT * FROM table2 WHERE surname =
> > '$NAME' ");
> > For whatever reason the *~ matching does not work in PHP4 (ie surname
*~ )
> > (or more precisely I can't get it to work)
> >
> > Any suggestions?
> >
> > Many thanks.
> >
> >
> >
> >
> >
> > _______________________________
> > Rick Frank
> > Dufferin Research
> >
> > mailto:rickf(at)dufferinresearch(dot)com
> > ________________________________
> >
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Papp Gyozo 2001-11-16 07:15:06 Re: Re: data type casting to numbers with intval() or doubleval()
Previous Message Peter 2001-11-16 05:37:40 Re: Nextval