我是sql的新手。我试图浏览所有与商店代码相对应的记录,但由于某种原因,sql只向我显示最新的记录。 我正在使用的代码是
$currentShopID = 467;
$sql = 'SELECT events.shopID AS ShopID, events.eventID AS EventID
FROM db1.events AS events
WHERE events.shopID IN ('.$currentShopID.')';
shopID 467有10条记录,但它只显示最新记录?
更新: 以下是函数
中的所有代码function loadSomeOtherStuff($sids) {
$currentShopID = implode(',', $sids);
$sql = 'SELECT events.shopID AS ShopID, events.eventID AS EventID
FROM db1.events AS events
WHERE events.centreid IN (' . $currentShopID . ')';
$this->_db->setQuery($sql);
$event = $this->_db->loadAssocList();
if (is_null($event)) {
throw new Exception($this->_db->getErrorMsg());
}
foreach($event as $row) {
$this->_dataBySid[$row['ShopID']]['Events']['Shop Code'] = $row['ShopID'];
$this->_dataBySid[$row['ShopID']]['Events']['Events'] = $row['EventID'];
}
}
答案 0 :(得分:1)
添加一个空数组以显示所有记录
$this->_dataBySid[$row['ShopID']]['Events']['Events'][] = $row['EventID'];