我遇到了CakePHP 1.3應用程序的問題,我不確定它是代碼問題還是數據庫問題。CakePHP 1.3「Missing Controller」錯誤 - 控制器存在
我在我的控制器的一個非常簡單的功能,每當我添加查詢部分到控制器,我得到以下(真氣,完全無用的)錯誤消息:
Missing Controller
Error: InternalError.htmlController could not be found.
Error: Create the class InternalError.htmlController below in file:
app/controllers/internal_error.html_controller.php
這裏是型號ForecastZones
class ForecastZone extends AppModel {
var $name = 'ForecastZone';
var $displayField = 'name';
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
'State' => array(
'className' => 'State',
'foreignKey' => 'state_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
var $hasMany = array(
'ForecastZonePoly' => array(
'className' => 'ForecastZonePoly',
'foreignKey' => 'forecast_zone_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
}
這裏是控制器功能莫名其妙地失敗:
function poly($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid forecast zone', true));
$this->redirect(array('action' => 'index'));
}
$this->layout = false;
$result = $this->ForecastZone->query("SELECT coords FROM forecast_zone_polies WHERE forecast_zone_id = $id;");
$this->set('forecastZone', $result);
}
每當我把這個控制器動作稱爲CakePHP史詩都會失敗。它掛起很長時間......然後,而不是告訴我一些有用的東西,比如「數據庫查詢花費太長時間」或「模型關聯破壞」或類似的東西......它只是放棄並給我這個完整的BS錯誤信息。
這不是路徑問題,路徑是正確的。如果我刪除$ result變量,一切工作正常,我得到適當的「forecastZone未設置」錯誤消息。這個問題的癥結似乎是一個永遠需要的查詢,然後Cake沒有正確地報告錯誤消息。
請幫我解決這個問題。非常令人沮喪......不是任何一個詞的「蛋糕」。
編輯:我想補充一點,我原來一直在使用
$this->ForecastZone->read(null,$id);
來獲取數據,但掛&失敗查詢不停發生的事情,所以我切換到原始查詢中可能改變的希望一些東西。
編輯2:
更多的東西我想: 該行添加到我的控制器的頂部:
var $uses = array('ForecastZone','ForecastZonePolies');
,然後試圖做的事情「正確的方式」仍然失敗。啊!
$result = $this->ForecastZonePolies->find('all',array('conditions' => array('ForecastZonePolies.forecast_zone_id' => $id)));
$result = $this->ForecastZone->ForecastZonePolies->find('all',array('conditions' => array('ForecastZonePolies.forecast_zone_id' => $id)));
這些工作都沒有。
你訪問的網址是什麼?此外,這看起來像一個潛在的SQL注入。是否有一個原因爲什麼你正在進行手動查詢呼叫?檢查app/tmp/logs是否有任何提示。 – tigrang
我訴諸手動查詢,因爲$ this-> ForecastZone-> read(null,$ id);以$ this-> ForecastZone-> query()的方式執行失敗。 – DirtyBirdNJ
做一個'調試(Inflector :: tableize('ForecastZonePoly'));'。你得到了什麼?也許它未能實現政策。編輯:其實,它看起來應該是'$ this-> ForcastZone-> ForcastZonePoly-> find('all','conditions'...))或者find('list')''你需要。它不清楚。嘗試清除您的緩存在tmp目錄 – tigrang