For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > May 2007 > Re: PEAR DB getCol









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 Re: PEAR DB getCol
Mark Wiesemann

2007-05-23, 7:03 pm

Hi John,

the right place for such questions is the pear-general list.

John Mambo wrote:
> I was just wondering what is the use of the second parameter (mixed $col = 0
> ) in DB getCol.
> If we are only getting one column why should provide two columns in the
> select statement and then add a parameter to get that column?
> For example
>
> $data =& $db->getCol('SELECT cf, df FROM foo', 1);
>
> can simply be accomplished by
>
> $data =& $db->getCol('SELECT df FROM foo');


The second parameter is optional. In simple cases like your second
example you can just use only the first parameter, of course. In more
complex cases, or, if you want to re-use an already existing query, you
can specify the column number of name to get the right column.

Regards,
Mark

--
http://www.markwiesemann.eu
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com