note 105097 added to pdostatement.fetch

From: Date: Wed, 27 Jul 2011 16:17:28 +0000
Subject: note 105097 added to pdostatement.fetch
Groups: php.notes 
Request: Send a blank email to php-notes+get-181936@lists.php.net to get a copy of this message
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. ---- Server IP: 193.231.122.254 Probable Submitter: 61.49.155.127 ---- Manual Page -- http://www.php.net/manual/en/pdostatement.fetch.php Edit -- https://master.php.net/note/edit/105097 Del: integrated -- https://master.php.net/note/delete/105097/integrated Del: useless -- https://master.php.net/note/delete/105097/useless Del: bad code -- https://master.php.net/note/delete/105097/bad+code Del: spam -- https://master.php.net/note/delete/105097/spam Del: non-english -- https://master.php.net/note/delete/105097/non-english Del: in docs -- https://master.php.net/note/delete/105097/in+docs Del: other reasons-- https://master.php.net/note/delete/105097 Reject -- https://master.php.net/note/reject/105097 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#181936) next »