Welcome Guest, Not a member yet? Register   Sign In
Oracle limit() bug
#1

[eluser]inari[/eluser]
Code:
$this->db->join('contacts','contacts.co_id=activities.co_id','left');
$this->db->join('employees','employees.e_id=activities.e_id','left');
        
$this->db->limit(10);
$this->db->order_by('activities.a_date','desc');
$this->db->order_by('activities.a_id','desc');
        
        
$data = $this->db->get_where('activities',array('activities.c_id' =>$id))->result();

Produces data from oracle:

Code:
Array
(
    [0] => stdClass Object
        (
            [a_id] => 301
            [a_date] => 1210802400
            [qcsj_c000000000500002] => 1
            [a_comment] => wewewe
            [a_subject] => wewe
            [qcsj_c000000000500000] => 2
            [qcsj_c000000000700000] =>
            [a_status] => 1
            [qcsj_c000000000500001] => 2
            [qcsj_c000000000500003] => 1
            [co_name] => Milivoj
            [co_surname] => Trtica
            [co_position] => Poreznik
            [co_tel] => 01/8888588
            [co_fax] => 2
            [co_email] => [email protected]
            [qcsj_c000000000700001] =>
            [e_name] =>
            [e_surname] =>
            [rnum] => 1
        )

)

These fields with strange names are some weird response from oracle when using same column names in many tables. I guess that this Oracle handle to prevent fields with the same name, but they only comes when using limit.

Without limit:

Code:
$this->db->join('contacts','contacts.co_id=activities.co_id','left');
$this->db->join('employees','employees.e_id=activities.e_id','left');
        
$this->db->order_by('activities.a_date','desc');
$this->db->order_by('activities.a_id','desc');
        
        
$data = $this->db->get_where('activities',array('activities.c_id' =>$id))->result();

produces:

Code:
Array
(
    [0] => stdClass Object
        (
            [a_id] => 301
            [a_date] => 1210802400
            [c_id] => 1
            [a_comment] => wewewe
            [a_subject] => wewe
            [co_id] => 2
            [e_id] =>
            [a_status] => 1
            [co_name] => Milivoj
            [co_surname] => Trtica
            [co_position] => Poreznik
            [co_tel] => 01/8888588
            [co_fax] => 2
            [co_email] => [email protected]
            [e_name] =>
            [e_surname] =>
        )

)



Any help how to use limit and to keep original column names is welcome.
#2

[eluser]Derek Allard[/eluser]
Which version of Oracle Inari?
#3

[eluser]inari[/eluser]
Version XE 10g
#4

[eluser]Derek Allard[/eluser]
The driver is for OCI8. I know they are similar, but not identical. I don't have an Oracle db to test against unfortunately, so any additional guidance you could provide would be appreciated.
#5

[eluser]inari[/eluser]
Query that produces that weird column names is:

Code:
SELECT * FROM (select inner_query.*, rownum rnum FROM
(SELECT * FROM activities LEFT JOIN contacts ON contacts.co_id=activities.co_id
    LEFT JOIN employees ON employees.e_id=activities.e_id WHERE activities.c_id = '2'
    ORDER BY activities.a_date desc, activities.a_id desc )
inner_query WHERE rownum < 10)

What is this inner_query? I can't even google it out.


I don't see what is wrong? Please tell me what may I try to change in this query to make it work?
Any ideas?




Theme © iAndrew 2016 - Forum software by © MyBB