You are here: Re: [PHP] PDO & pdo_odbc « PHP « IT news, forums, messages
Re: [PHP] PDO & pdo_odbc

Posted by Curt Zirzow on 12/29/05 09:07

On Wed, Dec 28, 2005 at 02:14:43PM +0100, Markus Fischer wrote:
> 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'));
> ...

Just out of curiosity, how does this perform:

$p->exec('INSERT ... VALUES('test1', 'test2'));

> ...
> 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.

yeah a crash is bad. I'm not familiar with windows installs so I
dont really know if it is a bad install or related to php's
pdo_odbc driver.

>
> Am I doing something conceptual wrong?

The code looks like it should perform as you have it. Although if
this is just for one insert statment i would use the $dbh->exec()
method instead. The prepare/execute method is more for batching a
bunch of queries:

$stmt = $dbh->prepare('insert into foo(value) values(?)');
for($i=0; $i < 10; $i++) {
$stmt->execute(array($i));
}

But then again it should be working either way.

Curt.
--
cat .signature: No such file or directory

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация