[dev] History getByTimestamp
Mikael Geijer
mikael at nufort.net
Mon Oct 20 05:53:21 PDT 2003
Hi all.
New on this list. Working w the new history-method Chuck added recently
- getByTimestamp. Works perfectly when only the two first arguments are used
Parameters:
* @param string $cmp The comparison operator (<, >, <=, >=, or =) to
* check the timestamps with.
* @param integer $ts The timestamp to compare against.
* @param array $filters (optional) An array of additional (ANDed)
criteria.
* each array value should be an array with 3
entries:
* 'op' - the operator to compare this
field with.
* 'field' - the history field being
compared (i.e., 'action').
* 'value' - the value to check for (i.e.,
'add').
When I try to use the third parameter, $filters, it produces an SQL like:
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.history' AND
(attribute_key = 'ts' AND attribute_value > '1066379566' AND
attribute_key = 'action' AND attribute_value = 'update')
I don't think this will work, or am I missing something obvious? There's
multiple conditions on the same column and this will result in 0 hits.
The attributes table looks like
+-------------+----------------+---------------+---------------------------------------------------+
| category_id | attribute_name | attribute_key |
attribute_value |
+-------------+----------------+---------------+---------------------------------------------------+
.
.
| 482 | 0 | action |
update |
| 482 | 0 | ts |
1066640922 |
.
.
I guess you need a self-join, something like
select a.category_id from horde_category_attributes a,
horde_category_attributes b where a.category_id = b.category_id and
(a.attribute_key = 'ts' and b.attribute_key = 'action') and (
a.attribute_value > '1066379566' and b.attribute_value = 'update');
Complicates it quite a lot. Maybe there's some simple way to work this out?
Cheers
/Mikael Geijer
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=- Mikael Geijer, nufort HB (nufort.net), Oebb AB (oebb.net)
=- mobile: +46 70 7455239 office +46 70 7455239
=- email: mikael at nufort.net
=- snail: Kyrklunden 8, 122 32 Enskede, Sweden
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=
More information about the dev
mailing list