6.0.0-git
2019-04-24

[#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 2011-09-20 (2773 days ago)
Due
Updated 2011-10-07 (2756 days ago)
Assigned
Resolved 2011-10-07 (2756 days ago)
Milestone
Patch Yes

History
2011-10-07 16:38:35 Jan Schneider Assigned to Jan Schneider
State ⇒ Resolved
 
2011-10-07 16:38:16 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
2011-10-07 16:38:12 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
2011-10-07 16:38:07 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
2011-09-22 04:04:47 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).
2011-09-21 19:35:08 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.
2011-09-21 18:37:29 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.
2011-09-21 08:22:44 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.
2011-09-21 02:27:26 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

2011-09-20 08:10:13 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.
2011-09-20 03:31:25 lfbm (dot) andamentos (at) gmail (dot) com Comment #1
Type ⇒ Enhancement
State ⇒ New
Priority ⇒ 1. Low
Summary ⇒ DISTINCT sql query feature in Horde/Rdo/Query.php
Queue ⇒ Horde Framework Packages
Milestone ⇒
Patch ⇒ Yes
New Attachment: 0001-Added-sql-DISTINCT-query-feature.patch Download
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