Обсуждение: Re: How can I bind query parameters to variables ?

Поиск
Список
Период
Сортировка

Re: How can I bind query parameters to variables ?

От
Timothy Madden
Дата:
On Mon, May 18, 2009 at 9:13 PM, Timothy Madden <terminatorul@gmail.com> wrote:
> Hello
>
> I am using PostgreSQL 8.3.7 and psqlODBC 08.03.0400.
>
> I would like to prepare queries with parameters and bind the
> parameters to php variables on execution.
> I use php 5.2.9-1 with dbg-2.15.5 with PDO and PDO_ODBC drivers on
> Windows XP (SP3).
>
> When I use
>         PDOStatement->bindParam(parameter, value, type)
> and then execute the INSERT statement I get no error but no record is inserted !
>
[...]
>
> Do you know what can I do to get the bindParam() php call working ? Am
> I doing something wrong ?
>
> I want to insert/fetch BIT VARYING columns ("AttachmentsData") with
> bindParam, and it does not work.
> Using a php string instead of a stream is I think a bad ideea, as file
> attachments can be arbitrary large.

Ok I got it: I forgot to call PDOStatement->execute() after the calls to
bindParam() to bind php variables to query parameters. My fault !

Still the problem is I could not use Large Object data type in ODBC to
insert values
in my BIT VARYING column. It said the parameter is of type lo, which I
created as in
the how-to, but the columns is BIT VARYING. Using CAST() on the
parameter did not
help. :(


Thank you
Timothy Madden

Re: How can I bind query parameters to variables ?

От
Rainer Bauer
Дата:
Hello Timothy,

TM> Still the problem is I could not use Large Object data type in
TM> ODBC to insert values in my BIT VARYING column. It said the
TM> parameter is of type lo, which I created as in the how-to, but the
TM> columns is BIT VARYING. Using CAST() on the parameter did not
TM> help. :(

I don't think you will ever be happy if you try to use a bit field to
store binary data. Use bytea [1] instead (the 'lo' type has the
disadvantage the the data is not stored inside the table).

Note that the support for BIT VARYING was dropped in SQL:2003 [2].
SQL:2003 has the BLOB datatype to store binary data and SQL:2008 will
have 2 new types: BINARY and BINARY VARYING.

Rainer

[1] <http://www.postgresql.org/docs/8.3/static/datatype-binary.html>
[2] <http://en.wikipedia.org/wiki/SQL2003>


Re: How can I bind query parameters to variables ?

От
Timothy Madden
Дата:
On Tue, May 19, 2009 at 7:43 PM, Rainer Bauer <usenet@munnin.com> wrote:
> Hello Timothy,
>
> TM> Still the problem is I could not use Large Object data type in
> TM> ODBC to insert values in my BIT VARYING column. It said the
> TM> parameter is of type lo, which I created as in the how-to, but the
> TM> columns is BIT VARYING. Using CAST() on the parameter did not
> TM> help. :(
>
> I don't think you will ever be happy if you try to use a bit field to
> store binary data. Use bytea [1] instead (the 'lo' type has the
> disadvantage the the data is not stored inside the table).
>
> Note that the support for BIT VARYING was dropped in SQL:2003 [2].
> SQL:2003 has the BLOB datatype to store binary data and SQL:2008 will
> have 2 new types: BINARY and BINARY VARYING.

So now I am left with no standard way of using binary data în PostgreSQL :(.

I guess I will have to stick to VARBIT until better times ...

Thank you,
Timothy Madden