note 105097 rejected from pdostatement.fetch by thiago

From: Date: Thu, 28 Jul 2011 05:06:38 +0000
Subject: note 105097 rejected from pdostatement.fetch by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181949@lists.php.net to get a copy of this message
Note Submitter: sonforest at gmail ---- As my opinion to Typer85‘s doubt: I think it's not a bug for PDO.Although you destroy the Instance of PDO,the object of statement exists . It's a good idea to try a new prepare and execute by a new statement,you will discover the truth. Just as following: try { $this->pdo = $this->getPDO (); $this->pdo->setAttribute ( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $statement = $this->pdo->prepare ( $this->sql ); //$statement->bindParam ( ':pa', $this->pa, PDO::PARAM_STR ); $statement->execute (array($this->pa)); while ($row=$statement->fetch(PDO::FETCH_LAZY)){ $this->html .= $row->projectid.'&emsp;'; $this->html .= $row->project.'&emsp;'; $this->html .= $row->invid.'&emsp;'; $this->html .= $row->invname.'<br />'; } $statement->closeCursor(); $nextsql = 'select projectid,project,invid,invname from center'; $stmt = $this->pdo->prepare($nextsql); $this->pdo = null; $stmt->execute(); while ($rows=$stmt->fetch(PDO::FETCH_LAZY)){ $this->html .= $rows->projectid.'&emsp;'; $this->html .= $rows->project.'&emsp;'; $this->html .= $rows->invid.'&emsp;'; $this->html .= $rows->invname.'<br />'; } } catch ( PDOException $pdoex ) { $this->html .= 'Database ERROR'; $this->html .= 'sql:'.$this->sql; $this->html .= 'ERROR:'.$pdoex->getMessage(); } Good luck.

« previous php.notes (#181949) next »