我创建了一个应用程序“脊梁”一类的,我需要这个功能来查询数据库,并返回一个多维的,看起来像这样:在PHP5中,如何从数据库查询创建关联数组?
$myArray = ("name"=>"John", "dob"=>"January 5, 1955");
当然的数据数组是从数据库查询。 但是,“姓名”和“出生日期”将是数据库列名和“约翰”和“1955年1月5日”将是列
这里的价值是我的代码:
public function getFrame($id) {
$getFrameQuery = "SELECT * FROM " . DB_FRAMETABLE . "WHERE `fhid`=" . $this->quote_smart($id);
$getFrameRecord = $db->query_first($getFrameQuery);
}
任何帮助是极大的赞赏!
Josh
http://www.ricocheting.com/scripts/php_mysql_wrapper.php – 2010-03-01 20:18:56
谢谢。我以什么类型的阵列作为未来参考的例子? – 2010-03-01 20:21:41
@josh brown:一个关联数组。 http://php.net/manual/en/language.types.array.php – jasonbar 2010-03-01 20:22:28