我在 MODX Revolution 2.7.3 中使用 xpdo 在與 modx 安裝相同的數據庫中插入自定義表和額外數據。一切工作正常,只是表中的更改需要大約 20 分鐘才能顯示在 xpod 查詢中。例如,我有一個包含成人字段的聯系人表。在表單中,我有一個下拉框,其中選項是成人聯系人。它工作正常,但當您更改聯系人的成人狀態時,下拉列表中的選項需要 20 分鐘才能反映更改。請參閱下面我的代碼$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貢獻1848條經驗 獲得超2個贊
使用 時似乎默認啟用緩存getCollection()
,請嘗試false
作為第三個參數傳遞。
$collections?=?$modx->getCollection($class,?null,?false);
您可能還必須傳遞一個空數組作為第二個參數,文檔有點沖突。
$collections?=?$modx->getCollection($class,?[],?false);
編輯
顯然,片段結果也會被緩存,甚至不會訪問數據庫,除非使用無緩存語法調用它們[[!tag]]
。使用該!
指令應該繞過此特定片段的緩存,這是可以的,因為這是最小的數據庫查詢。
- 1 回答
- 0 關注
- 172 瀏覽
添加回答
舉報
0/150
提交
取消