diff --git a/src/IDF/Commit.php b/src/IDF/Commit.php index 70414aa..6398d91 100644 --- a/src/IDF/Commit.php +++ b/src/IDF/Commit.php @@ -127,6 +127,7 @@ class IDF_Commit extends Pluf_Model { IDF_Timeline::remove($this); IDF_Search::remove($this); + IDF_Gconf::dropForModel($this); } /** diff --git a/src/IDF/Gconf.php b/src/IDF/Gconf.php index ad09ef8..0923b46 100644 --- a/src/IDF/Gconf.php +++ b/src/IDF/Gconf.php @@ -153,6 +153,32 @@ class IDF_Gconf extends Pluf_Model } } + /** + * Collection selection. + * + * Suppose you have 5 objects with associated meta data in the + * Gconf storage, if you load the data independently for each + * object, you end up with 5 SELECT queries. With 25 objects, 25 + * SELECT. You can select with one query all the data and merge in + * the code. It is faster. The collection selection get a + * model_class and a list of ids and returns an id indexed array + * of associative array data. This is for read only access as you + * do not get a series of Gconf objects. + */ + public static function collect($class, $ids) + { + $gconf = new IDF_Gconf(); + $stmpl = sprintf('model_class=%%s AND model_id IN (%s)', + implode(',' , $ids)); + $sql = new Pluf_SQL($stmpl, array($class)); + $out = array_fill_keys($ids, array()); + foreach ($gconf->getList(array('filter' => $sql->gen())) as $c) { + $out[$c->model_id][$c->vkey] = $c->vdesc; + } + + return $out; + } + /** * Drop the conf of a model. *