【问题标题】:I want to display all the records from the Table using For loop [closed]我想使用 For 循环显示表中的所有记录[关闭]
【发布时间】: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


【解决方案1】:
$result = $read->getSelect()->getAdapter()->fetchAll('SELECT * from cust_college');

【讨论】:

  • 您好 Guerra 感谢您的回复,但此查询未运行。请告诉我要运行的不同代码
  • 嗨 Guerra 非常感谢你。我的查询正在运行。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-08
  • 2021-07-31
  • 1970-01-01
  • 2021-10-15
  • 1970-01-01
相关资源
最近更新 更多