protected function getRelation($content)
    {
        $tablename = $this->getTablename("relations");

        $ids = Arr::column($content, 'id');

        if (empty($ids)) {
            return;
        }

        // Get the contenttype from first $content
        $first = reset($content);
        $contenttype = isset($first->contenttype['key']) ? $first->contenttype['key'] : $first->contenttype['slug'];

        $query = sprintf(
            "SELECT * FROM %s WHERE from_contenttype=? AND from_id IN (?) ORDER BY id",
            $tablename
        );
        $params = [$contenttype, $ids];
        $paramTypes = [\PDO::PARAM_STR, DoctrineConn::PARAM_INT_ARRAY];
        $rows = $this->app['db']->executeQuery($query, $params, $paramTypes)->fetchAll();

        foreach ($rows as $row) {
            $content[$row['from_id']]->setRelation($row['to_contenttype'], $row['to_id']);
        }

        // switch it, flip it and reverse it. wop wop wop.
        $query = sprintf(
            "SELECT * FROM %s WHERE to_contenttype=? AND to_id IN (?) ORDER BY id",
            $tablename
        );
        $params = [$contenttype, $ids];
        $paramTypes = [\PDO::PARAM_STR, DoctrineConn::PARAM_INT_ARRAY];
        $rows = $this->app['db']->executeQuery($query, $params, $paramTypes)->fetchAll();

        foreach ($rows as $row) {
            $content[$row['to_id']]->setRelation($row['from_contenttype'], $row['from_id']);
        }
    }