Re: PEAR DB getAssoc()
| From: | Pete Morganic | Date: | Fri, 11 Jul 2003 09:57:48 +0000 |
| Subject: | Re: PEAR DB getAssoc() | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-29197@lists.php.net to get a copy of this message | ||
$sql = ' select contact_id, contact_name from contacts';
$contacts = $db->getAssoc($sql);
also try getAll which will give u a different result
$contacts = $db->getAll($sql);
pete
Jacob Marble wrote:
Hey all-Could someone give an example of how to use the DB_Common::getAssoc()function? I'm trying to get an table into an array, and var_dump() shows that the array is not associative. Here's the code: $sql = "select * from sr_names"; $table = $db->getAssoc($sql); echo var_dump($table);And here's the output:array(1) { [1]=> array(16) {[0]=> string(5) "Jacob" [1]=> string(6) "Marble" [2]=> NULL<etc...>As I understand it, an associative array should return something morelike: array(1) { [1]=> array(16) {['firstname']=> string(5) "Jacob" ['lastname']=> string(6) "Marble" ['email']=> NULL<etc...>Or am I showing off my newness... ;-) Any help greatly appreciated!!Jake LandEZ