我有以下代碼可以在流浪環境中正常運行,但在服務器中失敗。無法弄清楚原因。CakePHP 3:數據庫語法錯誤或訪問衝突問題
$settingsQuery = $this->Configurations->find()
->select([
'id',
'name',
'value',
'description',
'editable',
'keyPrefix' => "SUBSTR(name FROM 1 FOR POSITION('.' IN name) - 1)"
])->order('name');
如果我註釋掉這部分//'keyPrefix' => "SUBSTR(name FROM 1 FOR POSITION('.' IN name) - 1)"
代碼執行沒有問題。這有些問題,但只在服務器上,而不在本地開發。
我收到以下錯誤:在Ubuntu的盒子
我在PHP 5.6運行CakePHP的3.4和MySQL 5.6。
通過我的流浪者設置(DEV)生成的SQL查詢時,試圖通phpMyAdmin的運行良好
SELECT Configurations.id AS `Configurations__id`, Configurations.name AS `Configurations__name`, Configurations.value AS `Configurations__value`, Configurations.description AS `Configurations__description`, Configurations.editable AS `Configurations__editable`, SUBSTR(name FROM 1 FOR POSITION('.' IN name) - 1) AS `keyPrefix` FROM settings_configurations Configurations ORDER BY name
在您的MySQL服務器上啓用查詢日誌記錄,並檢查SQL確切到達那裏。 – ndm
@ndm我會嘗試。謝謝! –