No results returning when using parameters on a Prepared Statement (PHP + ODBC + SQLBase)

Discussion forum about all things SqlBase or SqlTalk
renato.oliveira
Brazil
Posts: 2
Joined: 21 Oct 2020, 18:16
Location: Brazil

No results returning when using parameters on a Prepared Statement (PHP + ODBC + SQLBase)

Post by renato.oliveira » 22 Sep 2022, 14:16

No results returning when using parameters on a Prepared Statement (PHP + ODBC + SQLBase)

Tools (all 64 bits):
PHP 7.3.5
ODBC
SQL Base 12.3

I'm trying to fetch results from a query that have parameters, using PDOStatement, but nothing returns and no error occurs.
Does anyone know if there is support for parametrized queries with PHP + ODBC + SQLBase?

CODE THAT DOESN'T WORK:

Code: Select all

<?php
$pdo = new PDO("odbc:DSN", "user", "password");
$query = "
    SELECT column
    FROM table
    WHERE column = ?
";
$search = "term";
$statement = $pdo->prepare($query);
$statement->bindParam(1, $search);
$statement->execute();
$result = $statement->fetchAll(\PDO::FETCH_ASSOC);
var_dump($result); // returns an empty array
Result from $pdo->errorInfo()

Code: Select all

Array
(
    [0] => 00000
    [1] => 
    [2] => 
)
Result from $statement->errorInfo()

Code: Select all

Array
(
    [0] => 00000
    [1] => 0
    [2] =>  ((null)[0] at (null):0)
    [3] => 
)
Result from $statement->debugDumpParams()

Code: Select all

SQL: [70] 
    SELECT column
    FROM table
    WHERE column = ?

Params:  1
Key: Position #0:
paramno=0
name=[0] ""
is_param=1
param_type=2
CODE THAT WORKS (no parameters):

Code: Select all

<?php
$pdo = new PDO("odbc:DSN", "user", "password");
$query = "
    SELECT column
    FROM table
    WHERE column = 'term'
";
$statement = $pdo->prepare($query);
$statement->execute();
$result = $statement->fetchAll(\PDO::FETCH_ASSOC);
var_dump($result); // return all data from table.column

SIDE NOTE:
I'm able to run Prepared Statement with parameters using C# + ODBC + SQLBase and Java + JDBC + SQLBase.

Thanks in advance!

Return to “SqlBase General Discussion”

Who is online

Users browsing this forum: No registered users and 0 guests