0
我是一個總新手到SQL。我試圖拉取所有與商店代碼相對應的記錄,但由於某些原因,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'];
}
}
告訴我們你的代碼的其餘部分。很可能你只是在PHP代碼中檢索整個結果的第一行(它包含所有10行)。 – Tularis
謝謝,已經完成了! – Dave
'loadAssocList()'這個方法做了什麼? –