[dev] Links API + performance

Bo Daley bo at tilda.com.au
Sun Oct 19 21:00:16 PDT 2003


Quoting Chuck Hagenbuch <chuck at horde.org>:

> > Does the Categories driver support searching for categories on the basis of
> > multiple attributes?
>
> Yes. It'd very much help to see what you're trying to pass it, but take a
> look
> at horde/lib/Share.php for a pretty complex set of criteria.

cool -- I can see what that code in lib/Share.php is trying to do, but I have a
suspicion it might not actually be producing SQL that returns the right
results..

This is an example of a set of criteria that I'm trying to build for Links:

$criteria = array(
    'AND' => array(
        // link_type == $link_type
        array(
            'AND' => array(
                array('field' => 'key', 'op' => '=', 'test' => 'link_type'),
                array('field' => 'value', 'op' => '=', 'test'=>$link_type))),
        // from_key == $from_key
        array(
            'AND' => array(
            array('field' => 'key', 'op' => '=', 'test' => 'from_key'),
            array('field' => 'value', 'op' => '=', 'test' => $from_key))),
        // from_value == $from_value
        array(
            'AND' => array(
            array('field' => 'key', 'op' => '=', 'test' => 'from_value'),
            array('field' => 'value', 'op' => '=', 'test' => $from_value)))));


Using getCategoriesByAttributes() (and some real links data) this produces SQL
that looks like this:

SELECT DISTINCT a.category_id, c.category_name
FROM horde_category_attributes a
LEFT JOIN horde_categories c ON a.category_id = c.category_id
WHERE c.group_uid = 'horde.links'
AND ((attribute_key = 'link_type'
    AND attribute_value = 'tickets/client')
    AND (attribute_key = 'from_key'
    AND attribute_value = 'module_id')
    AND (attribute_key = 'from_value'
    AND attribute_value = '15'))


Which won't return any results from the database. I think there would need to be
some more joins across to the horde_category_attributes table for a query like
that to work.. hmmm

bo.





More information about the dev mailing list