|
Posted by Markus Fischer on 12/28/05 15:14
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
Navigation:
[Reply to this message]
|