【发布时间】:2013-07-11 06:08:05
【问题描述】:
我很少有 if else 语句只返回真或假,而且每个语句都不能正常工作。我尝试了很多方法,但不知道问题所在。如果有人解决这个问题,将会非常有帮助。
这是我的模型代码
function exists($email){
$this->db->where('email',$email);
$query=$this->db->get('member_info');
echo "model is called"; // after execution this text is shown but not the others
if ($query->num_rows == 1) {
return true;
echo "i got one";
}else{
return false;
echo "i got nothing";
}
}
这是我的控制器
function is_exists($email){
echo "this is loaded"; //this line works properly
if($this->validation_model->exists($email)){
return false;
echo "true"; //this doesn't
}else{
return true;
echo "false"; // this doesn't
}
}
【问题讨论】:
-
$query->num_rows() 试试这个
-
return之后的任何内容都不会运行。return退出函数。
标签: php codeigniter if-statement