NYCPHP Meetup

NYPHP.org

[nycphp-talk] Handling MySQL result sets

Michael Myers myersm at optonline.net
Wed Oct 29 23:54:45 EST 2003


On Wednesday, October 29, 2003, at 11:40  PM, Chris Snyder wrote:

> $records = array();
> while ( $array = mysql_fetch_assoc($result) ){
>    $records[$array['pmid']] = $array;
> }

Yikes!  I *did* miss the obvious. I was making it harder than necessary 
when I tried to build the keyed array:

	$details = array();
	$the_keys = array('doi', 'pii', 'pst', 'volume', 'issue', 'page', 
'source', 'title', 'authors', 'affiliation');
	
	while ($row = mysql_fetch_array($refs)) {
		$details['pmid'] = array();
		foreach ($the_keys as $key) {
			array_push($details['pmid'], $key => $row[$key]);
		}
	}

Thanks for the tip.

--mpm




More information about the talk mailing list