3
我剛開始使用PHP命名空間。我在不同的文件PHP主義與命名空間的關係
在這兩個文件中的兩個模型類首先我聲明命名空間
命名歐盟\編輯\ sixImport \ importViewer \模型;
第一類:
類登錄延伸\ Doctrine_Record
$this->hasMany('eu\ed\sixImport\importViewer\models\DataSource as DataSource', array(
'local' => 'id',
'foreign' => 'logId'));//setup relationship in setUp method
第二類:
類的DataSource延伸\ Doctrine_Record
$this->hasOne('eu\ed\sixImport\importViewer\models\Log as Log', array(
'local' => 'logId',
'foreign' => 'id'));//setup relationship in setUp method
一切正常,直到我做這樣的事情
$query = \Doctrine_Query::create()
->select('log.*')
->from('eu\ed\sixImport\importViewer\models\Log log')
->leftJoin("log.DataSource")
->orderBy("log.id DESC");
$requiredPage = (($startingRow - ($startingRow%$rowsRequired))/$rowsRequired) + 1;
$pager = new \Doctrine_Pager($query, $requiredPage, $rowsRequired);
$res = $pager->execute();
$this->logsPageCount = $pager->getNumResults();
print_r($res[0]["DataSource"]->toArray());//it fails on access to relationship
比主義拋出異常 未捕獲的異常與消息「找不到類歐盟\版」在C「Doctrine_Exception」:\ WAMP \ WWW \ importViewer \資源\ doctrine \ Doctrine-1.1.5 \ lib \ Doctrine \ Table.php:293 ...
從異常中,你可以看到,它尋找類'eu \ ed'。反斜槓[s]削減了類名的其餘部分,並且顯然未找到類。你能否給我一些建議,如何解決這個問題?
謝謝
兩件事;一,你的PHP版本是什麼? 二,嘗試使用雙引號和雙反斜槓。它不應該有所作爲,但你永遠不會知道。 – Qix 2010-12-03 16:07:58