Caucho Forums

Caucho Forums (http://forum.caucho.com//index.php)
-   Quercus (http://forum.caucho.com//forumdisplay.php?f=5)
-   -   multiple prepared statements using PDO in php (http://forum.caucho.com//showthread.php?t=32572)

remaus 12-27-2013 10:14 PM

multiple prepared statements using PDO in php
 
I have a lot of php code that runs against a MySQL MyISAM database using the old (deprecated) mysql driver. I am trying to get the applications to run under Resin/quercus (4.0.37) with the desire to use multiple prepared statements against a single database connection. However, we keep running into the following error.

C:\resin-4.0.37\webapps\ROOT\testPdoStatements.php:21: Fatal Error: Uncaught exception of type 'PDOException' with message 'SQLSTATE[S1000]: No operations allowed after statement closed'

The code is fairly simple. I get a connection, prepare 2 statements but when I execute the first, the error is thrown. If I only prepare the one statement and execute, it works fine. This is show stopper for us. We need to prepare multiple statements. Does anyone have an example?

<?php

$pdo = new PDO("java:comp/env/jdbc/mysql");

// grumble
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

// preparations
$s = "select * from ItemCtlg where Str = :catalog";
$stmt1 = $pdo->prepare($s, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
$stmt1->bindParam(':catalog', $Catalog, PDO::PARAM_STR);

$c = "select * from PartsOeStore where Str = :store";
$stmt2 = $pdo->prepare($c, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
$stmt2->bindParam(':store', $Store, PDO::PARAM_STR);

// executions
$Catalog = 'myCatalog';
$Store = 'myStore';

$stmt1->execute();

==> produces error.

nam 01-02-2014 05:40 PM

Hi remaus,

I just fixed this for the upcoming 4.0.39 release. Let me know if you would like a snapshot release.


All times are GMT. The time now is 11:48 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.