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'))));
您是否尝试过得到查询查找正在生成,并手动运行该数据库?你可以通过在/app/Config/core.php中将debug设置为2并添加echo $ this-> element('sql_dump')来获得输出它所经历的查询的蛋糕。到输出 – gabe3886