Cakephp 将输入的数据从数据库字段匹配到文本框


cakephp matching inputed data to textbox from database fields

我是 cakephp 的新手,我目前正在开发这个应用程序,我需要(出于安全目的)将输入的学生 ID 数据与我的学生列表表中的数据相匹配。因此,在我的学生列表表中,我有两个字段,一个是id,另一个是学生ID,因此每当学生想要注册网站时,他/她都需要输入学生ID,并且当输入的学生ID不在数据库中时,他/她无法注册。

我有这个视图/添加代码

echo $this->Form->input('studentlist_id', array('type'=>'text', 'label'=>'Student ID'));

和我的型号代码

var $name = 'Studentlist';
var $displayField = 'studentid';
var $validate = array(
    'id' => array(
        'notempty' => array(
            'rule' => array('notempty'),

和我的users_controller代码

$studentlists = $this->User->Studentlist->find('list');
    $this->set(compact('studentlists'));

请帮忙...我一直在搜索和调整代码,但似乎找不到答案......我就像是蛋糕的新手,所以我真的很抱歉提前

......
这可能会

对您有所帮助,

$count = $this->User->find('count', array('conditions'=>array('User.studentid'=>$_POST['studentlist_id']))); 
if($count > 0){
echo "Student Exist";
}else {
***do something***
}