note 72565 deleted from pdo.query by googleguy

From: Date: Tue, 22 Oct 2013 15:00:14 +0000
Subject: note 72565 deleted from pdo.query by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197292@lists.php.net to get a copy of this message
Note Submitter: ts at tpdada dot art dot pl ---- Look out for re-using this same variable for PDOStatement twice. You should always clear it if you want use it again. <?php /* WRONG */ $oPDO = new PDO(); $oPDOStatement = $oPDO->query('SELECT something'); /* making something with $oPDOStatement, i.e. fetch() */ $oPDOStatement = $oPDO->query('SELECT something completly different'); /* and now $oPDOStatement is unuseful, fetch() doesn't returns result etc. */ ?> But... <?php /* GOOD */ $oPDO = new PDO(); $oPDOStatement = $oPDO->query('SELECT something'); /* making something with $oPDOStatement, i.e. fetch() */ /* and destroy poor, little object as we had used it */ $oPDOStatement = null; $oPDOStatement = $oPDO->query('SELECT something completly different'); /* and everything works fine */ ?>

« previous php.notes (#197292) next »