Elgg\Database\RelationshipsTable::check PHP Method

check() public method

This function lets you ask "Is $guid_one a $relationship of $guid_two?"
public check ( integer $guid_one, string $relationship, integer $guid_two ) : ElggRelationship | false
$guid_one integer GUID of the subject entity of the relationship
$relationship string Type of the relationship
$guid_two integer GUID of the target entity of the relationship
return ElggRelationship | false Depending on success
    public function check($guid_one, $relationship, $guid_two)
    {
        $query = "\n\t\t\tSELECT * FROM {$this->db->prefix}entity_relationships\n\t\t\tWHERE guid_one = :guid1\n\t\t\t  AND relationship = :relationship\n\t\t\t  AND guid_two = :guid2\n\t\t\tLIMIT 1\n\t\t";
        $params = [':guid1' => (int) $guid_one, ':guid2' => (int) $guid_two, ':relationship' => $relationship];
        $row = $this->rowToElggRelationship($this->db->getDataRow($query, null, $params));
        if ($row) {
            return $row;
        }
        return false;
    }