pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter <peterh@600ml.com.au>
To: Jesus Aneiros <aneiros@ucfinfo.ucf.edu.cu>
To: PostgreSQL PHP <pgsql-php@postgresql.org>
Subject: Re: Wildcard queries via PHP4
Date: Fri, 16 Nov 2001 16:50:42 +1100
Message-ID: <009d01c16e62$a0c0e110$0300000a@600mlPeterPC1> (raw)
References: <Pine.LNX.4.10.10104052227240.12145-100000@ucfinfo.ucf.edu.cu>

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@ucfinfo.ucf.edu.cu>
To: <beloshapka@mnogo.ru>
Cc: <pgsql-php@postgresql.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@dufferinresearch.com
> > ________________________________
> >
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>




view thread (7+ messages)

Message-ID: <009d01c16e62$a0c0e110$0300000a@600mlPeterPC1>
Permalink:  ../009d01c16e62$a0c0e110$0300000a@600mlPeterPC1/
Also on:    postgresql.org/message-id/009d01c16e62$a0c0e110$0300000a@600mlPeterPC1

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: peterh@600ml.com.au, aneiros@ucfinfo.ucf.edu.cu
  Subject: Re: Wildcard queries via PHP4
  In-Reply-To: <009d01c16e62$a0c0e110$0300000a@600mlPeterPC1>
  References: <Pine.LNX.4.10.10104052227240.12145-100000@ucfinfo.ucf.edu.cu> <009d01c16e62$a0c0e110$0300000a@600mlPeterPC1>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox