Re: PDO and SAP HANA prepared statements issue
| From: | Karl DeSaulniers | Date: | Tue, 26 Jan 2016 13:18:56 +0000 |
| Subject: | Re: PDO and SAP HANA prepared statements issue | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-49083@lists.php.net to get a copy of this message | ||
On Jan 26, 2016, at 7:10 AM, Alko Kotalko <alko.kotalko@gmail.com> wrote:
> Hi,
>
> I have a working connection from PHP to SAP HANA through PDO and regular
> ODBC commands.
>
> The issue is that through PDO I can not get any prepared statements to
> work. None of the notations (?, $, :) work. The response from the server
> (fetch) gets me empty field values for all selected columns and if I try
> fetchAll the PHP script runs out of memory.
>
> ODBC commands actually work with the ? and colon ($) notations. But not
> with colon (:). I suppose this is due to the lack of named parameters
> support in ODBC commands (haven't actually confirmed that though). The $
> notation brings me the closest to named parameters because a specific
> number can be repeated.
>
> For example:
> "SELECT * FROM dummy WHERE col1=$1 AND col2=$2 AND col3=$1" works.
>
> However it is not ideal. I would like to know if anyone has any experience
> with SAP HANA and I can offer my help and participation in order to debug
> the possible problems with PDO<->HANA connectivity issues (in regards to
> prepared statements).
>
> BR Aleš
Pardon me for asking, but shouldn't this line..
"SELECT * FROM dummy WHERE col1=$1 AND col2=$2 AND col3=$1"
be
"SELECT * FROM dummy WHERE col1=".$1." AND col2=".$2." AND
col3=".$1." "
or like this
"SELECT * FROM dummy WHERE col1='".$1."' AND
col2='".$2."' AND col3='".$1."' "
?
I have found that letting php create the string without the quotes and periods in a SQL statement
can cause issues.
Don't ask me why it causes issues, I couldn't tell you :) Just my experience.
Best,
Karl DeSaulniers
Design Drumm
http://designdrumm.com