Re: PDO concerns

From: Date: Mon, 28 Feb 2005 15:04:24 +0000
Subject: Re: PDO concerns
References: 1 2 3 4 5  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-2091@lists.php.net to get a copy of this message
It works because you are re-assigning $stm with a new value; that causes the old $stm to be deleted prior to creating the new one; in other words, it doesn't have to be NULL that you assign to close/delete the statement object. --Wez. On Mon, 28 Feb 2005 08:23:00 -0600, Richard Thomas <lists@cyberlot.net> wrote: > There is something diffrent however between a PDO::query and a > PDO::prepare and execute, Because 2 prepare/executes in a row work > without having to declare anything NULL, Run the code there is no > confusion on my part in how this works, Well there was confusion in that > I assumed that since 2 prepare/executes do work without declaring the > stm null the fact that 2 querys didn't had to be a bug in my mind. > > $dsn = 'mysql:dbname=mysql;host=localhost'; > $db1 = new PDO($dsn, 'root', ''); > $db1->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION); > > > $stm = $db1->prepare('SELECT * FROM help_category LIMIT 1'); > $stm->execute(); > print_r($stm->fetch(PDO_FETCH_ASSOC)); > > $stm = $db1->prepare('SELECT * FROM help_category LIMIT 1'); > $stm->execute(); > print_r($stm->fetch(PDO_FETCH_ASSOC)); > > Shouldn't work but does?

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