/** * Return a relationship. * * @param int $id The ID of a relationship * * @return mixed */ function get_relationship($id) { global $CONFIG; $id = (int) $id; $query = "SELECT * from {$CONFIG->dbprefix}entity_relationships where id={$id}"; return row_to_elggrelationship(get_data_row($query)); }
/** * Check if a relationship exists between two entities. If so, the relationship object is returned. * * This function lets you ask "Is $guid_one a $relationship of $guid_two?" * * @param int $guid_one GUID of the subject entity of the relationship * @param string $relationship Type of the relationship * @param int $guid_two GUID of the target entity of the relationship * * @return ElggRelationship|false Depending on success */ function check_entity_relationship($guid_one, $relationship, $guid_two) { global $CONFIG; $guid_one = (int) $guid_one; $relationship = sanitise_string($relationship); $guid_two = (int) $guid_two; $query = "SELECT * FROM {$CONFIG->dbprefix}entity_relationships\n\t\tWHERE guid_one={$guid_one}\n\t\t\tAND relationship='{$relationship}'\n\t\t\tAND guid_two={$guid_two} limit 1"; $row = row_to_elggrelationship(get_data_row($query)); if ($row) { return $row; } return false; }
/** * Check if a relationship exists between two entities. If so, the relationship object is returned. * * This function lets you ask "Is $guid_one a $relationship of $guid_two?" * * @param int $guid_one GUID of the subject entity of the relationship * @param string $relationship Type of the relationship * @param int $guid_two GUID of the target entity of the relationship * * @return \ElggRelationship|false Depending on success */ function check($guid_one, $relationship, $guid_two) { $guid_one = (int) $guid_one; $relationship = sanitise_string($relationship); $guid_two = (int) $guid_two; $query = "SELECT * FROM {$this->CONFIG->dbprefix}entity_relationships\n\t\t\tWHERE guid_one={$guid_one}\n\t\t\t\tAND relationship='{$relationship}'\n\t\t\t\tAND guid_two={$guid_two} limit 1"; $row = row_to_elggrelationship(_elgg_services()->db->getDataRow($query)); if ($row) { return $row; } return false; }
/** * Check if a relationship exists between two entities. If so, the relationship object is returned. * * This function lets you ask "Is $guid_one a $relationship of $guid_two?" * * @param int $guid_one GUID of the subject entity of the relationship * @param string $relationship Type of the relationship * @param int $guid_two GUID of the target entity of the relationship * * @return \ElggRelationship|false Depending on success */ function check($guid_one, $relationship, $guid_two) { $guid_one = (int) $guid_one; $relationship = $this->db->sanitizeString($relationship); $guid_two = (int) $guid_two; $query = "\n\t\t\tSELECT * FROM {$this->db->getTablePrefix()}entity_relationships\n\t\t\tWHERE guid_one = {$guid_one}\n\t\t\t AND relationship = '{$relationship}'\n\t\t\t AND guid_two = {$guid_two}\n\t\t\tLIMIT 1\n\t\t"; $row = row_to_elggrelationship($this->db->getDataRow($query)); if ($row) { return $row; } return false; }