In Codeigniter use OR WHERE clause
<?php where()->or_where() ?>
If you want to select data from database you need to use
<?php where('column name',$value)->or_where('column name',$value); ?>
For example:
Here I have selected result from database use OR WHERE.
<?php $sec_qry=$this->db->select('*')->from('table')->where('user_email',$this->input->post('user_id'))->or_where('pen_name',$this->input->post('user_id'))->get(); $log_data=$sec_qry->result(); echo $sec_qry->num_rows(); ?>
If you need to use one more WHERE clause in your query then don’t use OR WHERE before any WHERE clause, it not work perfectly in your page. If you run your code perfectly then follow below example code.
Here I have used OR WHILE in the last position of the query. Try it fast.
<?php $sec_qry=$this->db->select('*')->from('table')->where('user_email',$this->input->post('user_id'))->where('user_password',md5($this->input->post('password')))->where('register_status','A')->or_where('pen',$this->input->post('user_id'))->get(); $log_data=$sec_qry->result(); echo $sec_qry->num_rows(); ?>
Question and answer is powered by AnsPress.io