PHPBuilder - DB Variable Dump

RSS Twitter

DB Variable Dump

by: Andy Chute
January 9, 2002

Version: 1.0

Type: Function

Category: Databases

License: GNU General Public License

Description: Takes the data in a table row and places it into variables of the field names. eg. $myrow["Id"] is now $Id Useful if you have a lot of fields and are using heredoc syntax which doesn't support array variables


*					DB Variable dump				*
*		created by Funktion Design and Media		*
*													*
*	Places a table row's results and places	them in *
*	variables with the DB Field Name.				*

	function dump_array($value,$key) {
		global $$key;
		$$key = $value;
		return true;
	require('dbconnect.php');									// Database Connection
	$result = mysql_query("select * from Whatever_Table");		// Standard Query
	if($currow = mysql_fetch_array($result)) {					// If there are results
		do {
			array_walk($currow,'dump_array');					// Dumps the current row into variables, $currow["Id"] is now $Id
		} while($currow = mysql_fetch_array($result));

Comment and Contribute

Your comment has been submitted and is pending approval.

Andy Chute



(Maximum characters: 1200). You have characters left.