6.0.0-beta1
7/19/25

[#10535] DISTINCT sql query feature in Horde/Rdo/Query.php
Summary DISTINCT sql query feature in Horde/Rdo/Query.php
Queue Horde Framework Packages
Queue Version Git master
Type Enhancement
State Resolved
Priority 1. Low
Owners jan (at) horde (dot) org
Requester lfbm.andamentos (at) gmail (dot) com
Created 09/20/2011 (5051 days ago)
Due
Updated 10/07/2011 (5034 days ago)
Assigned
Resolved 10/07/2011 (5034 days ago)
Milestone
Patch Yes

History
10/07/2011 04:38:35 PM Jan Schneider Assigned to Jan Schneider
State ⇒ Resolved
 
10/07/2011 04:38:16 PM Git Commit Comment #10 Reply to this comment
Changes have been made in Git for this ticket:

[jan] Add Horde_Rdo_Query#distinct() (Request #10535).

  2 files changed, 13 insertions(+), 9 deletions(-)
http://git.horde.org/horde-git/-/commit/1445e10b285786be126616888f7fbb1b1cfdffde
10/07/2011 04:38:12 PM Git Commit Comment #9 Reply to this comment
Changes have been made in Git for this ticket:

Optimize request 10535.

  1 files changed, 8 insertions(+), 13 deletions(-)
http://git.horde.org/horde-git/-/commit/206a971165a455b00ff27ad0d54bdbbf42725813
10/07/2011 04:38:07 PM Git Commit Comment #8 Reply to this comment
Changes have been made in Git for this ticket:

Added sql DISTINCT query feature.
Request: 10535
Signed-off-by: Jan Schneider <jan@horde.org>

  1 files changed, 29 insertions(+), 1 deletions(-)
http://git.horde.org/horde-git/-/commit/16e4609273a3a1df23f585b4a7527146b03d83a0
09/22/2011 04:04:47 AM lfbm (dot) andamentos (at) gmail (dot) com Comment #7
New Attachment: 0003-Added-sql-DISTINCT-query-feature.patch Download
Reply to this comment
My bad. I didn´t notice there was a magic __call method on 
Adapter/Base delegating calls to the Schema.

Attached is another patch.

The adapter->distinct() method should be called with proper arguments, 
so it knows when ORDER BY clause is also present in the query (which 
changes the DISTINCT clause a little bit for postgresql, for example).
09/21/2011 07:35:08 PM Jan Schneider Comment #6 Reply to this comment
http://dev.horde.org/api/framework/Db/Db/Adapter/Horde_Db_Adapter_Base_Schema.html#distinct

But it's really as easy as using $this->mapper->adapter->distinct() in 
Horde_Rdo_Query.
09/21/2011 06:37:29 PM lfbm (dot) andamentos (at) gmail (dot) com Comment #5 Reply to this comment
Hum, now I´m confused. Couldn´t find any distinct related method here: 
http://dev.horde.org/api/framework/Db/

I guess the solution is more complex than I was thinking. Anyway, I 
suggest leaving this ticket open for future implementation.
09/21/2011 08:22:44 AM Jan Schneider Comment #4 Reply to this comment
Sorry that I didn't catch that earlier: you need to use Horde_Db's 
distinct() method to add the DISTINCT to the query.
09/21/2011 02:27:26 AM lfbm (dot) andamentos (at) gmail (dot) com Comment #3
New Attachment: 0002-Added-sql-DISTINCT-query-feature.patch Download
Reply to this comment
Attached follows another patch.

$query->distinct() or $query->distinct(true) // Turns on distinct query
$query->distinct(false) // Turns off distinct query

09/20/2011 08:10:13 AM Jan Schneider Comment #2
State ⇒ Feedback
Reply to this comment
Looks good, but should also contain an option to unset the distinct 
flag, e.g. adding a boolean argument to the distinct() method that 
defaults to true.
09/20/2011 03:31:25 AM lfbm (dot) andamentos (at) gmail (dot) com Comment #1
State ⇒ New
New Attachment: 0001-Added-sql-DISTINCT-query-feature.patch Download
Patch ⇒ Yes
Milestone ⇒
Queue ⇒ Horde Framework Packages
Summary ⇒ DISTINCT sql query feature in Horde/Rdo/Query.php
Type ⇒ Enhancement
Priority ⇒ 1. Low
Reply to this comment
Zitat von Luis Felipe Marzagao/Andamentos <lfbm.andamentos@gmail.com>:

[Show Quoted Text - 11 lines]
That's more like a hack. We should add some feature to Horde_Rdo_Query 
instead that makes a query DISTINCT.

Jan.

- - - - - - - - - -

Attached is a suggestion.

Luis Felipe

Saved Queries