Home > Archive > PHP Pear > September 2005 > PEAR::DB getCol default behaviour
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
PEAR::DB getCol default behaviour
|
|
| Jeroen Houben 2005-09-26, 3:56 am |
| 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?
Jeroen
| |
| Lukas Smith 2005-09-26, 8:01 am |
| 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.
regards,
Lukas
| |
| Jeroen Houben 2005-09-26, 8:01 am |
| Lukas Smith wrote:
> Jeroen Houben wrote:
>
>
>
> 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
| |
| Lukas Smith 2005-09-26, 8:01 am |
| Jeroen Houben wrote:
> 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?
There is no way to do this ..
regards,
Lukas
|
|
|
|
|