繁体   English   中英

如何在php MVC中使用if else

[英]How to use if else in php MVC

我如何在MVC格式php中创建if else语句

我正在尝试将此代码放入我的控制器中

if(数据库 B 表 1 中 A 列的所有值都存在于数据库 B 表 2 中的 A 列中)

[Load Model A]

Else
[Load Model B]

请帮助我不知道是在控制器中还是在模型中编写它

    public function ownercount(){
    $this->db->selectCount('id');
    $this->db->from('owner_register');
    $this->db->order_by("id", "desc");
    $query = $this->db->get();
        $result = $query->result_array();
        return $result;
}

public function gymcount(){

    $this->db->selectCount('id');
    $this->db->from('gym');
    $this->db->order_by("id", "desc");
    $query = $this->db->get();
        $result = $query->result_array();
        return $result;

在我的控制器中,我把这个

            public function gym()
    {
        is_protected();

    $this->load->model->('adminmodel')
    $ownercount = $this->load->adminmodel->ownercount();

        $this->load->model->('adminmodel')
    $gymcount = $this->load->adminmodel->gymcount();

        if ($ownercount = $gymcount) {

            $data['message']=$this->Adminmodel->gymlist();
        $this->load->view('Admin/customer.php',$data);

            } else {
           $data['message']=$this->Adminmodel->gymlist1();
        $this->load->view('Admin/customer.php',$data);

           }  


}

这是我在控制器上写的内容,但出现 500http 错误

你用一个 SQL 的查询尝试过吗?

`从表1中选择count( ); select count( ) from table1 where colomnA in ( select colomnA from table2);

`

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM