Re: Weird SQL Problem - Mailing list pgsql-novice

From Michael Glaesemann
Subject Re: Weird SQL Problem
Date
Msg-id 0BAED329-0CD0-4BD0-87F9-0D925EC15C4B@myrealbox.com
Whole thread Raw
In response to Re: Weird SQL Problem  (<operationsengineer1@yahoo.com>)
List pgsql-novice
On Sep 9, 2005, at 7:03 AM, <operationsengineer1@yahoo.com>
<operationsengineer1@yahoo.com> wrote:

> $sql_insert = <<<_EOSQL
>
>     INSERT INTO t_customer (customer_name,
> customer_entry_date)
>     VALUES (?,?)
>
> _EOSQL;
>
> $result = $db->Execute($sql_insert,
> array($customer_name, CURRENT_TIMESTAMP));
>
> does using a heredoc preclude me from being able to
> bind variables to parameters or have i found another
> novel (to me, anyway!) way to jack my code up?

To PHP, the result of heredoc, single-quotes, or double-quotes is
just a string, so I can't think of why heredoc should have anything
to do with it. What does jump out at me is that you're using
CURRENT_TIMESTAMP outside of the string. The bare word
CURRENT_TIMESTAMP only has meaning in SQL, i.e., the SQL string
passed back to database server. Here you're using it in a PHP array,
which I'm guessing PHP is trying to interpret as a constant, and one
that's probably undefined. I'd put it in query itself. Bind variables
are for just that: variables, i.e., things that change.

Besides what appears in the browser, be sure to check your logs as
well. I keep Apache's error log open all the time when I'm coding, as
there are often errors that don't manifest themselves in the browser.

As an aside, I haven't used ADOdb's variable binding before, so I
don't know how well it compares with Perl DBI's, which does the right
thing with strings automatically (no need to escape the string). I'll
have to look into it more. If it *does*, that would be really nice.

Michael Glaesemann
grzm myrealbox com



pgsql-novice by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: What's the point of creating a schema?
Next
From: "Pradeepkumar, Pyatalo (IE10)"
Date:
Subject: Re: [ADMIN] Please help - libpq API