Subject Re: [firebird-php] Inserting NULLs as parameter
Author Jochem Maas
Jiri Cincura schreef:
> Hello,
>
> I have a simple function in PHP:
> @fbird_query('update or insert into polls (id, question, visible)
> values (?, ?, ?) returning new.id', $this->id, $this->question,
> $this->visible);
>
> and when i.e. id param is null (indicating, that this is new, unsaved
> object) I get error "Parameter 1: non-empty value required in".
>
> Is there any way to use parameters and nulls?

the field doesn't allow a NULL, that's why you get the error.
one way to tackle this is use an insert trigger that sets
the new.id (from the relevant generator) when the given insert id
is not set ... and change your query to:

update or insert into polls (question, visible) values (?, ?) returning new.id

which means in effect using 2 queries instead of 1.
alternatively if you wnat to stick with a single query then you
have to 'pre-generate' the id.

>