Monday 01 January 2007 3:34:43 pm
Hi Martin I am not that proficient with SQL so I might be wrong here, but I don't see any even halfways acceptable way to use something like distinct or group by for filtering on multiple attributes. The problem is that each attribute has it's own row. It might thus be possible to first group by the name and fetch the ids of objects that are unique by their name. Then you could use the result of this and group by the price and so on. Unfortunately apart from being terrible inefficient there is no way to fetch content that is unique by the combination of name and price like this. So I think an extended attribute filter or something else SQL related not a solution to this problem (although I certainly wouldn't mind being proven wrong here). Patching the fetch function is not that easy. eZContentObjectTreeNode::subtree creates the query string out out of the parameters and then calls ezdb::arrayquery with this string. As changing the SQL does not seem to be feasible, you could try to patch ezdb::arrayquery according to your needs (e.g. checking whether there is already a row with certain attributes in the resulting array). But as this function is used by about all other queries, this is quite risky business. After the call to ezdb::arrayquery the function eZContentObjectTreeNode::makeObjectsArray is called to create objects out of each row. You could maybe add you filter here but again this function is used about everywhere so changing this is rather risky. You could try to create your own fetch function which is basically a copy of the eZContentObjectTreeNode::subtree function and the functions used in there and add your check for uniqueness in your copy of ezdb::arrayquery so you have less rows in the returned resultset. I don't know whether this is a good solution, at least you will have to check at each EZ update whether this will still work. An easier option would be just to write a template operator that takes a hash of the names of the unique attributes and the resultset of the fetch function and then iterates through the resultset and returns an array of unique content. This is certainly the easiest, most maintenable and flexible solution, although it will of course not be as fast. Well, I am curious to see what solution you will finally end up with, so I would appreciate if you could post at least an outline of your solution. Thanks Claudia
|