PDO_odbc: Parameter binding

From: Date: Thu, 25 Nov 2004 12:49:03 +0000
Subject: PDO_odbc: Parameter binding
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-1660@lists.php.net to get a copy of this message
Hi, I'm trying to connect from SuSE Linux 9.0 through unixODBC to a DB2 database living in an IBM iSeries server. I have successfully used this layout in different projects, mainly using PEAR DB for database access. Now I'd like to use PDO to call stored procedures. The problem is that I can't bind parameters (not even for a simple SQL query), since PDO_odbc silently dies. Following Wez's example in http://netevil.org/node.php?nid=44, I tried this code: try {
        $dbh = new PDO("odbc:iSeriesDSN", "user", "pass");
        $dbh->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION);
$dbh->exec("create table test(name varchar(255) not null primary key, value varchar(255))");
        // insert some data using a prepared statement
        $stmt = $dbh->prepare("insert into test (name, value) values (:name, :value)");
        $stmt->bindParam(':name', $name, PDO_PARAM_STR, 64);
        $stmt->bindParam(':value', $value, PDO_PARAM_STR, 64);
        $name = 'Foo';
        $value = 'Bar';
        $stmt->execute();
} catch (PDOException $e) {
        echo "Error: " . $e->getMessage() . " - line " . $e->getLine();
} Connection is established, the 'test' table is created fine, but the execution crashes when it arrives to the *prepare* statement. I'm not getting an error from the iSeries server (I do receive errors though if I try to create an existing table). Could it be a problem of PDO_odbc? Thanks in advance, -- Daniel

« previous php.pecl.dev (#1660) next »