20 $id = $this->db->nextId($this->db->quoteIdentifier(self::TABLE_NAME));
23 $this->db->insert($this->db->quoteIdentifier(self::TABLE_NAME), array(
24 'id' => array(
'integer', $id),
25 'title' => array(
'text', $a_title),
26 'latitude' => array(
'float', $a_latitude),
27 'longitude' => array(
'float', $a_longitude),
28 'expiration_timestamp' => array(
'timestamp', $a_expiration_timestamp->getTimestamp())
37 $a_expiration_timestamp
44 $query =
'Select * FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
45 ' WHERE id = ' . $this->db->quote($a_id,
'integer');
51 if($row = $this->db->fetchAssoc(
$result))
57 (
float)$row[
'latitude'],
58 (
float)$row[
'longitude'],
63 throw new \InvalidArgumentException(
"Unknown id for geolocation: $a_id");
69 $query =
'Select * FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
70 ' WHERE latitude = ' . $this->db->quote($a_latitude,
'float') .
71 ' AND longitude = ' . $this->db->quote($a_longitude,
'float');
78 while($row = $this->db->fetchAssoc(
$result))
84 (
float)$row[
'latitude'],
85 (
float)$row[
'longitude'],
97 $query =
'Select count(*) AS count FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
98 ' WHERE id = ' . $this->db->quote($a_id,
'integer');
110 $query =
'Select count(*) AS count FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
111 ' WHERE latitude = ' . $this->db->quote($a_latitude,
'float') .
112 ' AND longitude = ' . $this->db->quote($a_longitude,
'float');
124 $this->db->update($this->db->quoteIdentifier(self::TABLE_NAME),
126 array(
'title' => array($a_obj->
getTitle(),
'text')),
127 array(
'latitude' => array($a_obj->
getLatitude(),
'float')),
128 array(
'longitude' => array($a_obj->
getLongitude(),
'float')),
131 array(
'id' => array($a_obj->
getId(),
'int'))
138 $this->db->update($this->db->quoteIdentifier(self::TABLE_NAME),
140 array(
'expiration_timestamp' => array(
'timestamp', $a_update_timestamp->getTimestamp())),
142 array(
'latitude' => array($a_searched_latitude,
'float'),
143 'longitude' => array($a_searched_longitude,
'float'))
150 $query =
'DELETE FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
151 ' WHERE id = ' . $this->db->quote($a_id,
'integer');
154 $this->db->manipulate(
$query);
160 $query =
'DELETE FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
161 ' WHERE latitude < ' . $this->db->quote($a_latitude,
'float') .
162 ' AND longitude = ' . $this->db->quote($a_longitude,
'float');
165 $this->db->manipulate(
$query);
171 $query =
'DELETE FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
172 ' WHERE expiration_timestamp < ' . $this->db->quote(time(),
'timestamp');
175 $this->db->manipulate(
$query);
__construct(\ilDBInterfacee $a_db)
getExpirationAsTimestamp()
deleteGeoLocation(int $a_id)
Exaple for deleting single geo location identified by its id.
getGeoLocationsByCoordinates(float $a_latitude, float $a_longitude)
Example for reading an array of geo locations which have a given attribute.
getGeoLocationById(int $a_id)
Get a single geo location, identified by its id.
updateGeoLocationTimestampByCoordinates(float $a_searched_latitude, float $a_searched_longitude, \DateTimeImmutable $a_update_timestamp)
Example for updating multiple objects at once.
deleteGeoLocationsByCoordinates(float $a_latitude, float $a_longitude)
Example for a condition based deletion of multiple geo locations.
ifGeoLocationExistsById(int $a_id)
Example for checking if geo location with a certain id exists.
ifAnyGeoLocationExistsByCoordinates(float $a_latitude, float $a_longitude)
Example for checking if a geo location (one or more) with a given attribute exists.
updateGeoLocation(ilGeoLocation $a_obj)
Example for updating all attributes of a given geo location.
This code is just an example for the Repository Pattern! It is a basic interface to the 'ilGeoLocatio...
createGeoLocation(string $a_title, float $a_latitude, float $a_longitude, \DateTimeImmutable $a_expiration_timestamp)
Create a new geo location entry.
deleteExpiredGeoLocations()
Example for a condition based deletion of multiple geo locations.