[Beginner] Very Basic DB usage question

From: Date: Mon, 11 Jul 2005 00:13:23 +0000
Subject: [Beginner] Very Basic DB usage question
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19934@lists.php.net to get a copy of this message
Hello, Sorry for upsetting you with such basic questions, but I'm starting.. I have the following database table : id name 1 FOO 2 FOO2 3 FOO3 I would need to get the content of this table in the same way array("id" "name") I succeed i getting very sophisticated arrays but no to get a basic one I get for example : Array ( [0] => Array ( [id] => 1 [name] => FOO ) [1] => Array ( [id] => 2 [name] => FOO2 ) .... and so on Here is my function to fetch data function get_stuff () { $stuff = array(); $db =& DB::connect($this->demo_dsn, $this->demo_options); if (PEAR::isError($db)) { die($db->getMessage()); } $db->setFetchMode(DB_FETCHMODE_ASSOC); // Proceed with a query... $res =& $db->query('SELECT * FROM stuff_table'); // Always check that result is not an error if (PEAR::isError($res)) { die($res->getMessage()); } while ( $res->fetchInto($row)) { array_push($stuff, $row); // I MISERABLY FAIL HERE } // print_r($rstuff); return $stuff; }

« previous php.pear.general (#19934) next »