exists() public method

This function checks for the existence of an entity independent of access permissions. It is useful for situations when a user cannot access an entity and it must be determined whether entity has been deleted or the access level has changed.
public exists ( integer $guid ) : boolean
$guid integer The GUID of the entity
return boolean
コード例 #1
0
ファイル: PrivateSettingsTable.php プロジェクト: elgg/elgg
 /**
  * Sets a private setting for an entity.
  *
  * @param int    $entity_guid The entity GUID
  * @param string $name        The name of the setting
  * @param string $value       The value of the setting
  * @return bool
  */
 public function set($entity_guid, $name, $value)
 {
     $this->cache->clear($entity_guid);
     _elgg_services()->boot->invalidateCache();
     if (!$this->entities->exists($entity_guid)) {
         return false;
     }
     $query = "\n\t\t\tINSERT into {$this->table}\n\t\t\t(entity_guid, name, value) VALUES\n\t\t\t(:entity_guid, :name, :value)\n\t\t\tON DUPLICATE KEY UPDATE value = :value\n\t\t";
     $params = [':entity_guid' => (int) $entity_guid, ':name' => (string) $name, ':value' => (string) $value];
     $result = $this->db->insertData($query, $params);
     return $result !== false;
 }