Welcome Guest, Not a member yet? Register   Sign In
active record class limit 1 wiered
#1

[eluser]valuk[/eluser]
Hi. I can't solve this by myselfe. It look like that active record class auto append limit 1 in some situations.
Expample:

Model
Code:
function Get($options = array(), $count_results = FALSE)
    {
        if(isset($options['t_vloge_vloga_id']))
        {
            $this->db->where('t_vloge_vloga_id', $options['t_vloge_vloga_id']);
        }

        if(isset($options['t_lokacije_lokacija_id']))
        {
            $this->db->where('t_lokacije_lokacija_id', $options['t_lokacije_lokacija_id']);
        }

        if(isset($options['organizator_id']))
        {
            $this->db->where('organizator_id', $options['organizator_id']);
        }

        if(isset($options['t_uporabniki_uporabnik_id']))
        {
            $this->db->where('t_uporabniki_uporabnik_id', $options['t_uporabniki_uporabnik_id']);
        }

        if(isset($options['t_sole_sola_id']))
        {
            $this->db->where('t_sole_sola_id', $options['t_sole_sola_id']);
        }

        if(isset($options['t_tekmovanja_tekmovanje_id']))
        {
            $this->db->where('t_tekmovanja_tekmovanje_id', $options['t_tekmovanja_tekmovanje_id']);
        }

        if(isset($options['limit']) and isset($options['offset']))
        {
            $this->db->limit($options['limit'], $options['offset']);
        }
        else if(isset($options['limit']))
        {
            $this->db->limit($options['limit']);
        }

        if(isset($options['sort_by']) and isset($options['sort_direction']))
        {
            $this->db->order_by($options['sort_by'], $options['sort_direction']);
        }

        $query = $this->db->get('t_organizatorji');

        if($query->num_rows() == 0)
        {
            return false;
        }
        else if($query->num_rows() > 0 and !$count_results)
        {
            return $query->result();
        }
        else if($query->num_rows() > 0 and $count_results)
        {
            return $query->num_rows();
        }

and i call it in another model. The argument of Get method are array(
['t_tekmovanja_tekmovanje_id'] => 39, ['t_vloge_vloga_id'] => 15, ['t_lokacije_lokacija_id'] => 5).

The last_query method return this: SELECT * FROM (`t_organizatorji`) WHERE `t_vloge_vloga_id` = 15 AND `t_lokacije_lokacija_id` = '5' AND `t_tekmovanja_tekmovanje_id` = '39' LIMIT 1

Any ideas?




Theme © iAndrew 2016 - Forum software by © MyBB