我在 MODX Revolution 2.7.3 中使用 xpdo 在與 modx 安裝相同的數(shù)據(jù)庫(kù)中插入自定義表和額外數(shù)據(jù)。一切工作正常,只是表中的更改需要大約 20 分鐘才能顯示在 xpod 查詢中。例如,我有一個(gè)包含成人字段的聯(lián)系人表。在表單中,我有一個(gè)下拉框,其中選項(xiàng)是成人聯(lián)系人。它工作正常,但當(dāng)您更改聯(lián)系人的成人狀態(tài)時(shí),下拉列表中的選項(xiàng)需要 20 分鐘才能反映更改。請(qǐng)參閱下面我的代碼$class='Contacts';$fields = array_keys($modx->getFields($class));$collections = $modx->getCollection($class);foreach($collections as $collection) { if($collection->get($fields[4])=='YES'){ $output .= '<option value=' . $collection->get($fields[0]).'>'.$collection->get($fields[1])." ".$collection->get($fields[2]).'</option>'; }}return $output;There is only one table involved and the code for creating the table is: CREATE TABLE `cbdb_contacts` ( `contactID` int(11) NOT NULL, `firstname` varchar(15) COLLATE utf8_unicode_ci NOT NULL, `lastname` varchar(25) COLLATE utf8_unicode_ci NOT NULL, `dob` date NOT NULL, `adult` enum('YES','NO') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'NO', `mobile` text COLLATE utf8_unicode_ci NOT NULL, `landline` text COLLATE utf8_unicode_ci NOT NULL, `address` text COLLATE utf8_unicode_ci NOT NULL, `email` text COLLATE utf8_unicode_ci NOT NULL, `comments` longtext COLLATE utf8_unicode_ci NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1 回答

慕尼黑5688855
TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超2個(gè)贊
使用 時(shí)似乎默認(rèn)啟用緩存getCollection()
,請(qǐng)嘗試false
作為第三個(gè)參數(shù)傳遞。
$collections?=?$modx->getCollection($class,?null,?false);
您可能還必須傳遞一個(gè)空數(shù)組作為第二個(gè)參數(shù),文檔有點(diǎn)沖突。
$collections?=?$modx->getCollection($class,?[],?false);
編輯
顯然,片段結(jié)果也會(huì)被緩存,甚至不會(huì)訪問(wèn)數(shù)據(jù)庫(kù),除非使用無(wú)緩存語(yǔ)法調(diào)用它們[[!tag]]
。使用該!
指令應(yīng)該繞過(guò)此特定片段的緩存,這是可以的,因?yàn)檫@是最小的數(shù)據(jù)庫(kù)查詢。
- 1 回答
- 0 關(guān)注
- 191 瀏覽
添加回答
舉報(bào)
0/150
提交
取消