PDO & pdo_odbc
| From: | Markus Fischer | Date: | Wed, 28 Dec 2005 13:14:43 +0000 |
| Subject: | PDO & pdo_odbc | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-227926@lists.php.net to get a copy of this message | ||
Hi,
I'm using the following code in a PHP 5.1, Windows CLI environment:
$p = new PDO('odbc:driver={Microsoft Access Driver (*.mdb)};Dbq=beispieldatenbank.mdb');
$s = $p->prepare('INSERT INTO ADDRESSES(TITLE0, LASTNAME0) VALUES(?, ?)');
$s->execute(array('test1', 'test2'));
I'm always getting the last value of the array passed to execute in all the fields which have markers in the prepare statement, like I would have written:
INSERT INTO ADDRESSES(TITLE0, LASTNAME0) VALUES('test2', 'test2')
I also tried bindValue like this
$s = $p->prepare('INSERT INTO ADDRESSES(TITLE0, LASTNAME0) VALUES(?, ?)');
$s->bindValue(1, 'test1');
$s->bindValue(2, 'test2');
$s->execute();
or name values:
$s = $p->prepare('INSERT INTO ADDRESSES(TITLE0, LASTNAME0) VALUES(:a, :b)');
$s->bindValue(':a', 'test1');
$s->bindValue(':b', 'test2');
$s->execute();
but which all resulted in a row being inserted but the values were just empty.
When I tried something like this:
$s = $p->prepare('INSERT INTO ADDRESSES(TITLE0, LASTNAME0) VALUES(?, ?)');
$val1 = 'test1';
$val2 = 'test2';
$s->bindParam(1, $val1);
$s->bindParam(2, $val2);
$s->execute();
I even get a crash.
Am I doing something conceptual wrong?
thanks for any pointers,
- Markus