[dev] need help to understand content tagger getTags by tag-id.

roman stachura roman at stachura.ch
Wed Aug 17 07:06:15 UTC 2011


Am 16.08.2011 21:49, schrieb Michael J Rubinsky:
>
> [...]
> I don't have the code in front of me at the moment, so going from 
> memory here. First, to answer your question:
>
> "FROM ($inner) tagged1" is a sql subquery with a table alias. It 
> allows the subquery to act as a table with a 'object_id' column. So, 
> e.g., later in the query we join on "tagged1.object_id = 
> tagged2.object_id" the tagged1 table is actually the subquery results 
> presented as a table.
>
> If I'm reading the code correctly, the idea of this code is to return 
> tags that are present on objects where those objects are also tagged 
> with $args['tagId']. The radius determines the max number of other 
> objects to look at. For example: I have an object tagged with 'foo' 
> and 'bar', and another object tagged with 'foo'. If I run this query 
> with the tag_id for 'foo', it will return 'bar'. At least that's the 
> idea ;)

For this behaviour we need another WHERE clause:

WHERE tag_id != XXX

or we get as result 'foo' and 'bar' instead of 'bar'.

I am not sure how good the idea is, to limit the inner Query.
Performance concerns?

SELECT DISTINCT tagged2.tag_id AS tag_id, tag_name
FROM (
     SELECT object_id
     FROM rampage_tagged
     WHERE tag_id = XXX
*    LIMIT 0, 10 *
) AS tagged1
INNER JOIN rampage_tagged tagged2 ON tagged1.object_id = tagged2.object_id
INNER JOIN rampage_tags t ON tagged2.tag_id = t.tag_id
*WHERE tagged2.tag_id != XXX*
LIMIT 0, 10



>
> That being said, it looks like something might be wrong here, since 
> the limit value is unset() before it's used in the final query, might 
> be causing some WARNING to be rasied due to non-existant key.
>
> Are you having issues with this method? I still need to fill in some 
> areas of the unit tests, so any information on failing behavior would 
> be helpful.
>
>
Regards
roman


More information about the dev mailing list