Welcome Guest, Not a member yet? Register   Sign In
Where something and something SQL
#1

[eluser]kolxoznik1[/eluser]
I have read user_guide and do not found WHERE something AND something.

So I need to check WHERE a = 3 and a = 5

so as I understand

Quote: $this->db->where('user_id', $user_id);
$this->db->where('follow_id', $follow_id);


two WHERE mean AND ?

Code:
function add_follow($user_id, $follow_id)
    {
        $this->db->select('user_id');
        $this->db->where('user_id', $user_id);
        $this->db->where('follow_id', $follow_id);
        $query = $this->db->get('user_follow');
        if ($query->num_rows() == 0) {
            $this->db->set('user_id', $user_id);
            $this->db->set('follow_id', $follow_id);
            $this->db->insert('user_follow');        
        }
        return FALSE;
    }

is it correct?
#2

[eluser]Patrick Spence[/eluser]
[quote author="kolxoznik1" date="1328148220"]I have read user_guide and do not found WHERE something AND something.



is it correct? [/quote]

That's how I use it.
#3

[eluser]CroNiX[/eluser]
Yep, that's exactly what the example in the user guide shows for where() in active record.
Quote:$this->db->where('name', $name);
$this->db->where('title', $title);
$this->db->where('status', $status);

// WHERE name = 'Joe' AND title = 'boss' AND status = 'active'
#4

[eluser]vbsaltydog[/eluser]
Alternatively using method chaining:

Code:
$this->db
->where(‘name’, $name)
->where(‘title’, $title)
->where(‘status’, $status);




Theme © iAndrew 2016 - Forum software by © MyBB