Re: prepared SELECT and placeholders with NULL values

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Michael Lea <michael(dot)lea(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: prepared SELECT and placeholders with NULL values
Date: 2006-03-25 17:29:47
Message-ID: 20060325172947.GA23203@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Mar 23, 2006 at 15:24:16 -0600,
Michael Lea <michael(dot)lea(at)gmail(dot)com> wrote:
>
> $s = $db->prepare('SELECT id FROM person WHERE lname = ? AND fname = ?');
>
> But this does not, returning an empty list:
> $s->execute('Cher', undef);

= NULL will return NULL for every row and no rows will be selected by the
WHERE clause. This is how things are supposed to work according to the
standard.

It is hard to say what you might do without knowing more about what you
are doing, but a simple possibility may be to use the empty string ('') instead
of NULL in your data.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Travers 2006-03-25 18:11:35 Re: Advantages of PostgreSQL over MySQL 5.0
Previous Message Bruno Wolff III 2006-03-25 15:30:35 Re: Advantages of PostgreSQL over MySQL 5.0