普通网友 2018-01-29 14:03
浏览 66
已采纳

mysql中的where子句不起作用

I am working on a project using php codeigniter,i am using mysql select query to fetch all data from database where isactive field is equal to 1.but i am unable to do it.below is the function where i have writtten the query.

Code:

public function displayinfo3()
        {
            $user_id = $this->session->userdata('user_id');
            if($user_id)
            {
                $this->load->library('datatables');
                $this->datatables
                                    ->select("user_type.user_type as user_type,user.user_name as user_name,user.first_name as first_name,user.middle_name as middle_name,user.last_name as last_name,user.user_id as Actions")
                            ->from("user")
                            ->where('isactive'==1)
                                                    ->join("user_type","user_type.user_type_id=user.user_type_id","left")
                            ->edit_column("Actions", 
                                                            "<center><div class='visible-md visible-lg hidden-sm hidden-xs'><div align='center'><div class='col-md-2'><form action='".base_url()."index.php/Registrationc/editpatient3' method='post'><input type='hidden' id='editp3' name='editp3' value='$1'><button title='EDIT PATIENT' class='tip btn btn-primary btn-xs' type='submit' value='Submit' ><i class='fa fa-edit'></i></button></form></div><div class='col-md-2'><a class=\"tip btn btn-danger btn-xs\" title='DELETE PATIENT' href='#' onclick=\"delete_patient('$1')\" ><i class=\"fa fa-trash-o\"></i></a></div></div></div></center>", "Actions");
                                                    // $this->datatables->unset_column('Sno.patient_id');<form action=""><div class='btn-group'>
                                       //<a class=\"tip btn btn-primary btn-xs\" onclick=\"edit_patient('$1')\" title='EDIT MAPPING' href='#' return false;\"><i class=\"fa fa-edit\"></i></a>                         
                            echo $this->datatables->generate();
             }
            else
            {
                redirect(base_url('Registrationc/extra1'));
            }  


}
  • 写回答

2条回答 默认 最新

  • doubinei1457 2018-01-29 14:08
    关注

    Replace ->where('isactive'==1) with ->where('isactive = 1')

    The first passes the result of the comparison of 'isactive' with 1 to the function. As 'isactive' is not equal to 1 you just pass a false value to your where statement.

    The second call passes the correct query string to be put in the where statement of the query.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。