Welcome Guest, Not a member yet? Register   Sign In
using $this->db->group_by() and $this->db->order_by() together
#4

[eluser]chefnelone[/eluser]
I have a table like:

id -- group -- colour -- order
1 -- 1 -- black -- 0
2 -- 2 -- blue -- 2
3 -- 2 -- yellow -- 1

then I run the query:
Code:
$this->db->group_by('group');
$this->db->order_by("order", "asc");


$data = $this->db->get('my_table');
$data = $data->result();


If I use $this->firephp->log( $data ); I get this array:

Code:
array(
[0] => stdClass(
id = 1
group = 1
colour = 'black'
orden = 0

)
[1] => stdClass(
id = 2
group = 2
colour = 'black'
orden = 2

)
)

But I need it to be (because order of 'yellow' is lower than 'blue')

Code:
array(
[0] => stdClass(
id = 1
group = 1
colour = 'black'
orden = 0

)
[1] => stdClass(
id = 3
group = 2
colour = 'yellow'
orden = 1

)
)


Messages In This Thread
using $this->db->group_by() and $this->db->order_by() together - by El Forum - 07-14-2010, 06:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB