/** * Create/refresh the relationship name cache from the database. * * @return array unique names */ function reason_refresh_relationship_names() { $cache = new ReasonObjectCache('reason_relationship_names'); $cache->lock(10); $dbq = new DBSelector(); $dbq->add_table('allowable_relationship'); $dbq->add_field('allowable_relationship', 'id'); $dbq->add_field('allowable_relationship', 'name'); $r = db_query($dbq->get_query(), 'Error getting relationship anmes in reason_refresh_relationship_names'); while ($row = mysql_fetch_array($r)) { $retrieved[$row['name']] = (int) $row['id']; } mysql_free_result($r); if (!empty($retrieved)) { if ($result = $cache->set($retrieved)) { relationship_id_of('site_to_type', false); // refresh the relationship_id_of static cache } $cache->unlock(); return $retrieved; } else { trigger_error('reason_refresh_relationship_names did not update the cache because no relationship names were retrieved'); } return array(); }