ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:learn_abstraction:key_value_pairs

This is an old revision of the document!


Key/Value Pairs

An often-used SQL construction is to read a table for a key/value pair. This can be used in creating Select Boxes, Radio groups etc. ADOdb contains a shortcut command getAssoc() to assist in the task.

$sql = "select emp_no, emp_name from employees";
 
$array = $db->getAssoc($sql);
 
print_r($array);
 
/*
* Returns
*/
array(
1000 =>'Joe Smith',
1001 =>'Fred Jones'
1002 => 'Arthur Dent'
);
v5/userguide/learn_abstraction/key_value_pairs.1458001298.txt.gz · Last modified: 2017/04/21 11:40 (external edit)