Welcome Guest, Not a member yet? Register   Sign In
Active records Distinct() Problem
#1

[eluser]Radiart[/eluser]
Code:
$this->db->distinct();
$this->db->select('content.title, comments.id_usera, comments.id_content, comments.id_content_type, comments.created_date');
$this->db->join('content', 'content.id_content = comments.id_content');
$this->db->group_by(array('created_date','id_content_type','id_content'));
$this->db->orderby('comments.created_date', "desc");
$this->db->limit(10);
$query = $this->db->get($this->table_name);
$result = $query->result();
return $result;

Why distinct not working?

Quote: * HIP HOP GROOVE FESTIVAL 2010 radi
* HIP HOP GROOVE FESTIVAL 2010 radi
* WinterJam Party 2008 radi
* Wirująca Strefa 2010 Bboying radi
* I Śląski Przegląd Spektakli Tańca… radi
* Wirująca Strefa 2010 Bboying
* Letnie Kursy Taneczne z uczestnikami…
* I Śląski Przegląd Spektakli Tańca…
* FNF SUPER SUMMER DANCE INTENSIVE 2010…
* FNF SUPER SUMMER DANCE INTENSIVE 2010…
#2

[eluser]jparent[/eluser]
Yeah, I have the same problem. I think is a bug or we don't use it properly.
#3

[eluser]InsiteFX[/eluser]
Try moving $this->db->distinct(); below $this->db->select();

It should be below your select.

InsiteFX
#4

[eluser]Radiart[/eluser]
[quote author="InsiteFX" date="1293652819"]Try moving $this->db->distinct(); below $this->db->select();

It should be below your select.

InsiteFX[/quote]

This changes nothing

If it change something I use CodeIgniter version 1.7.3
#5

[eluser]Radiart[/eluser]
There is an alternative?
#6

[eluser]idealws[/eluser]
I am not sure if you have found a fix for this or not. I thought I was having the same issue
due to the profiler showing the results returned were 80295 which is the complete count for
the table I was running the query on. When in fact there is only 51 being returned which is the proper number.

However I came to find out it was working properly and the profiler is just reporting the wrong
information.

I am using CI 2.0 however which could have the fix for this issue already in it.

Here is what my code looks like:
Code:
$abbr = array('AA','AE','AP','AS','DC','FM','GU','MH','MP','PR','PW');
$this->db->where_not_in('stateabbr', $abbr);        
$this->db->select('statename, stateabbr');
$this->db->distinct();
$this->db->order_by("stateabbr", "asc");
$query = $this->db->get('postalus');
if ($query->num_rows() >= 1){return $query->result();}else{return '0';};
return NULL;

Best Regards,
Ray




Theme © iAndrew 2016 - Forum software by © MyBB