$options = $db->fetchPairs("SELECT id, name FROM table ORDER BY name");
returns:
$options = array(
id1 => name1,
id2 => name2,
....
);
On Sunday 03 August 2008 01:11:46 Gordon Ross wrote:
> I'm new to Zend, and I'm trying to work out how to populate an HTML
> drop-down list from a SQL table easily (without having to write a bucket
> load of code)
>
> Searching the list I found
> http://www.nabble.com/how-to-use-fetchPairs()-td17545498.html - but this
> talks about sloctables which I don't know about.
>
> I also discovered
> http://www.zfforums.com/zend-framework-components-13/databases-20/how-do-i-
>fill-zend-form-select-db-769.html but this talks about fetchpairs, which
> appears to be something extra to standard PHP/Zend database APIs.
>
> Is there an easy way to populate a drop-down list from a SQL table in Zend
> framework/PHP?
>
> Thanks,
>
> GTG
--
Benjamin Eberlei
http://www.beberlei.de
没有评论:
发表评论