Welcome Guest, Not a member yet? Register   Sign In
1.7.0 handling mysql queries differently ... breaking a few of mine
#1

[eluser]skattabrain[/eluser]
So this used to work on 1.6.3, it should do the following ...

get from the table 'entries' that have 'active' = 1 that also have either 1 of the 2 items ...

entries.user_id = '.$this->session->userdata('user_id')

OR

entries.public = "1"


Code:
$this->db->from('entries');
$this->db->where('entries.active', '1');

$this->db->where('(entries.user_id = '.$this->session->userdata('user_id').' OR entries.public = "1")');
    
$this->db->join('projects', 'projects.project_id = entries.project_id');
$this->db->join('ci_users', 'ci_users.user_id = entries.user_id');
$this->db->order_by('entries.entry_id', 'desc');
$this->db->limit($limit);
$query = $this->db->get();

this is the code it creates ...

Code:
SELECT * FROM (`entries`)
JOIN `projects` ON `projects`.`project_id` = `entries`.`project_id`
JOIN `ci_users` ON `ci_users`.`user_id` = `entries`.`user_id`
WHERE `entries`.`active` = '1'
AND `(entries`.`user_id` = 3 OR entries.public = "1") ORDER BY `entries`.`entry_id` desc LIMIT 25

this is what it should create ...

Code:
SELECT * FROM (`entries`)
JOIN `projects` ON `projects`.`project_id` = `entries`.`project_id`
JOIN `ci_users` ON `ci_users`.`user_id` = `entries`.`user_id`
WHERE `entries`.`active` = '1'
AND (`entries`.`user_id` = 3 OR entries.public = "1")
ORDER BY `entries`.`entry_id` desc LIMIT 25


Messages In This Thread
1.7.0 handling mysql queries differently ... breaking a few of mine - by El Forum - 10-24-2008, 08:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB