Elgg\Database\Annotations::exists PHP Method

exists() public method

Check to see if a user has already created an annotation on an object
public exists ( integer $entity_guid, string $annotation_type, integer $owner_guid = null ) : boolean
$entity_guid integer Entity guid
$annotation_type string Type of annotation
$owner_guid integer Defaults to logged in user.
return boolean
    function exists($entity_guid, $annotation_type, $owner_guid = null)
    {
        if (!$owner_guid && !($owner_guid = $this->session->getLoggedInUserGuid())) {
            return false;
        }
        $sql = "SELECT id FROM {$this->db->prefix}annotations\n\t\t\t\tWHERE owner_guid = :owner_guid\n\t\t\t\tAND entity_guid = :entity_guid\n\t\t\t\tAND name = :annotation_type";
        $result = $this->db->getDataRow($sql, null, [':owner_guid' => (int) $owner_guid, ':entity_guid' => (int) $entity_guid, ':annotation_type' => $annotation_type]);
        return (bool) $result;
    }