I am trying to fetch data from whole mysql
database not in single table. It works when I try to search using LIKE
query but it works only with specific key.
I try to search who is admin so it will return all the data related (admin name
or email
) from mysql
table
I try this code :
$this->db->select()
->like('username', 'admin')
->like('email','admin@gmail.com')
->get('users');
Hope this will help you:
Use or_like
in your query and select clause should be like $this->db->select('*')
$username = 'your-username';
$email = 'your-email';
$results = $this->db->select('*')
->like('username', $username)
->or_like('email',$email)
->get('users')->result();
print_r($results);
If u want to get result with specific username
and email
u can also use where
clause like this :
$username = 'your-username';
$email = 'your-email';
$results = $this->db->select('*')
->where('username', $username)
->or_where('email',$email)
->get('users')->result();
print_r($results);
For more : https://www.codeigniter.com/user_guide/database/query_builder.html#looking-for-similar-data