Re: PEAR::DB getCol default behaviour

From: Date: Mon, 26 Sep 2005 09:35:19 +0000
Subject: Re: PEAR::DB getCol default behaviour
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21104@lists.php.net to get a copy of this message
Lukas Smith wrote:
Jeroen Houben wrote:
Hi, Consider this code: $sql = 'SELECT email FROM vw_event_persons WHERE event_id=!'; $emails = $db->getCol($sql, null, array(23)); I'm trying to skip the 2nd parameter, passing in NULL to leave it at its default value, which is 0. This however raises an error, saying :"field not found". When I pass in 0 like this: $emails = $db->getCol($sql, 0, array(23)); it works fine. I was under the impression that when you pass in NULL, the default parameter value (0) would get passed instead. Is this a bug?
No, if you specify a value for an optional parameter, than that value is used even if you pass in null.
Okay thanks, I didn't know that. So is there a way to just say skip this parameter, just use whatever it defaults to? I know you can just leave out parameters if they are at the end of the signature, but what if it's the first parameter you are trying to skip? Jeroen

« previous php.pear.general (#21104) next »