V
V
vista1x2015-03-01 17:55:29
PHP
vista1x, 2015-03-01 17:55:29

Stored query and ODBC?

There is a saved query in the MS Access database, the input of which is given two parameters: id1 and id2 (when a query is launched in the DBMS, this data is requested, because =[id1] and =[id2]).
How to do the same but from PHP?
The base connects through the ODBC driver.
From PHP I connect it through PDO.
I do it like this:

$sql = "SELECT * FROM qr1";
  $sth = $db->prepare($sql);
  $sth->execute(array(12,12));

I get the error: COUNT field incorrect: -3010 [Microsoft][Microsoft Access ODBC Driver] Too few parameters. Required 2
How to correctly call a stored query, and, in fact, how to correctly pass parameters there?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shaks, 2015-03-01
@shaks

$sth = $db->prepare("SELECT * FROM qr1 WHERE id1= :id1 AND id2 = :id2");
    $sth->execute(array(
        'id1'=> 12,
        'id2'=> 13,
    ));

:paramin your sql line is replaced with the array key of the same name (but without a colon), which you feed to the execute method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question