【发布时间】:2012-08-13 11:49:16
【问题描述】:
在这段代码中,我必须显示表(cust_college)中的所有记录。但是这个函数只返回该表的第一行而不是其他行。请告诉我解决方案
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
$a = "SELECT * from cust_college";
$qry = $read->query($a);
$res = $qry->fetch(PDO::FETCH_ASSOC); //fetch row
foreach ($res as $payment) {
echo $payment = $res[college];
echo $payment = $res[value_id];
echo $payment = $res[shop_id];
echo $payment = $res[cust_address];
}
$store = Mage::app()->getStore()->getCode();
【问题讨论】:
-
你自己的评论说明了一切: //fetch row not //fetch all rows
-
嘿,马克,我用 fetch_ASSOC 完成了所有概率,但仍然多次获得 1 行
-
你应该创建一个模型来访问表......这是使用magento和db的正确方法
标签: php magento magento-1.4 magento-1.6