From e916edc798f891fdb08e2fae9684afc02e3de9d3 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Fri, 10 Jul 2009 05:50:08 +0000 Subject: #502538 by catch: Add the ability to load multiple comments at once. --- modules/comment/comment.api.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'modules/comment/comment.api.php') diff --git a/modules/comment/comment.api.php b/modules/comment/comment.api.php index 92f247a86..acd23bfc3 100644 --- a/modules/comment/comment.api.php +++ b/modules/comment/comment.api.php @@ -33,6 +33,19 @@ function hook_comment_update($comment) { search_touch_node($comment->nid); } +/** + * Comments are being loaded from the database. + * + * @param $comments + * An array of comment objects indexed by cid. + */ +function hook_comment_load($comments) { + $result = db_query('SELECT cid, foo FROM {mytable} WHERE cid IN (:cids)', array(':cids' => array_keys($comments))); + foreach ($result as $record) { + $comments[$record->cid]->foo = $record->foo; + } +} + /** * The comment is being viewed. This hook can be used to add additional data to the comment before theming. * -- cgit v1.2.3