public function get_relations($source_site_id, $source_content_id, $type = 'post')
{
$cache_key = $this->get_cache_key($source_site_id, $source_content_id, $type);
$cache = wp_cache_get($cache_key, $this->cache_group);
if (is_array($cache)) {
return $cache;
}
$sql = "\nSELECT t.ml_blogid as site_id, t.ml_elementid as content_id\nFROM {$this->table} s\nINNER JOIN {$this->table} t\nON s.ml_source_blogid = t.ml_source_blogid\n\tAND s.ml_source_elementid = t.ml_source_elementid\n\tAND s.ml_type = t.ml_type\nWHERE s.ml_blogid = %d\n\tAND s.ml_elementid = %d\n\tAND s.ml_type = %s";
$query = $this->db->prepare($sql, $source_site_id, $source_content_id, $type);
$results = $this->db->get_results($query, ARRAY_A);
if (!$results) {
return [];
}
$output = [];
foreach ($results as $set) {
$output[(int) $set['site_id']] = (int) $set['content_id'];
}
wp_cache_set($cache_key, $output, $this->cache_group);
return $output;
}