我使用CakePHP 1.3
我正在尝试学习CakePHP,而我正在尝试重定向控制器。但我收到了警告,我根本无法重定向到其他行动。
这是打印的警告
Warning (2): array_merge() [function.array-merge]: Argument #2 is not an array [CORE/cake/libs/router.php, line 1078]
Warning (2): array_merge() [function.array-merge]: Argument #1 is not an array [CORE/cake/dispatcher.php, line 158]
Warning (2): call_user_func_array() expects parameter 2 to be array, string given [CORE/cake/dispatcher.php, line 204]
这是我的login_controller.php
以获取重定向到其他操作的控制器样本
<?php
class LoginController extends AppController {
var $uses = array();
function index() {
$result = 'empty';
if(isset($this->data)) {
$user = $this->data['user_txt'];
$pass = md5($this->data['pass_txt']);
$action = array('controller'=>'users','action'=>'login');
$params = array('user'=>$user,'pass'=>$pass);
$get_login = $this->requestAction($action,$params);
if($get_login===true) {
$result = 'exist';
}
}
$this->set('result', $result);
}
}
?>
这是user_controller.php
代码
<?php
class UsersController extends AppController {
function index() {
}
function login() {
$user = $this->request->params['user'];
$pass = $this->request->params['pass'];
$query = $this->User->find('all', array(
'conditions' => array('id'=>$user,'password'=>$pass)
));
$this->layout = false;
if (isset($query) && !empty($query)) {
return true;
}
else {
return compact($query);
}
}
}
?>
任何帮助都可以,谢谢