2015-04-30 70 views
0

我想在腳本中執行查找,但我相信我的狀況正在返回false。我試圖執行查找並提取與我的$data變量中的給定值匹配的所有記錄。我試圖比較BranchLicense.RegionCode$data,但沒有運氣。我也嘗試過比較_Session['Auth']['User']['region_code']。變量$data正在返回正確的值,但腳本不會返回正確的記錄。我在這裏做錯了什麼?這是我的代碼。查找方法返回假

//echo '<pre>'; print_r($_SESSION); echo '</pre>'; 
//$this->loadModel('AuthAcl.Users'); 

$data = $_SESSION['Auth']['User']['region_code']; 

//$data = $this->Users->find('all'); 

$new = $this->BranchLicense->find('all', array(
'conditions' => array('BranchLicense.RegionCode' == $data))); 
die(debug($new)); 

$this->layout = 'default'; 

//$this->set('branchLicenses', $this->BranchLicense->find('all', array(
//'conditions' => array('BranchLicense.RegionCode' === '$data')))); 
+0

您是否嘗試過得到查詢查找正在生成,並手動運行該數據庫?你可以通過在/app/Config/core.php中將debug設置爲2並添加echo $ this-> element('sql_dump')來獲得輸出它所經歷的查詢的蛋糕。到輸出 – gabe3886

回答

0

嘗試如下 -

$new = $this->BranchLicense->find('all', array(
    'conditions' => array('BranchLicense.RegionCode' => $data))); 
    die(debug($new)); 
+0

謝謝!!我早些時候嘗試過,但沒有奏效!好吧!再次感謝! – Spice1