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 title, latitude, longitude, expiration_timestamp' .
45 ' FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
46 ' WHERE id = ' . $this->db->quote($a_id,
'integer');
49 $result = $this->db->query($query);
52 if($row = $this->db->fetchAssoc($result))
58 (
float)$row[
'latitude'],
59 (
float)$row[
'longitude'],
64 throw new \InvalidArgumentException(
"Unknown id for geolocation: $a_id");
70 $query =
'SELECT title, expiration_timestamp' .
71 ' FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
72 ' WHERE latitude = ' . $this->db->quote($a_latitude,
'float') .
73 ' AND longitude = ' . $this->db->quote($a_longitude,
'float');
76 $result = $this->db->query($query);
80 while($row = $this->db->fetchAssoc($result))
99 $query =
'SELECT EXISTS(SELECT 1 FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
100 ' WHERE id = ' . $this->db->quote($a_id,
'integer') .
") AS count";
103 $result = $this->db->query($query);
106 return $result[
'count'] == 1;
112 $query =
'SELECT EXISTS(SELECT 1 FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
113 ' WHERE latitude = ' . $this->db->quote($a_latitude,
'float') .
114 ' AND longitude = ' . $this->db->quote($a_longitude,
'float') .
") AS count";
116 $result = $this->db->query($query);
119 return $result[
'count'] == 1;
125 $this->db->update($this->db->quoteIdentifier(self::TABLE_NAME),
127 array(
'title' => array($a_obj->
getTitle(),
'text')),
128 array(
'latitude' => array($a_obj->
getLatitude(),
'float')),
129 array(
'longitude' => array($a_obj->
getLongitude(),
'float')),
132 array(
'id' => array($a_obj->
getId(),
'int'))
139 $this->db->update($this->db->quoteIdentifier(self::TABLE_NAME),
141 array(
'expiration_timestamp' => array(
'timestamp', $a_update_timestamp->getTimestamp())),
143 array(
'latitude' => array($a_searched_latitude,
'float'),
144 'longitude' => array($a_searched_longitude,
'float'))
151 $query =
'DELETE FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
152 ' WHERE id = ' . $this->db->quote($a_id,
'integer');
155 $this->db->manipulate($query);
161 $query =
'DELETE FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
162 ' WHERE latitude < ' . $this->db->quote($a_latitude,
'float') .
163 ' AND longitude = ' . $this->db->quote($a_longitude,
'float');
166 $this->db->manipulate($query);
172 $query =
'DELETE FROM ' . $this->db->quoteIdentifier(self::TABLE_NAME) .
173 ' WHERE expiration_timestamp < ' . $this->db->quote(time(),
'timestamp');
176 $this->db->manipulate($query);
__construct(\ilDBInterface $a_db)
getExpirationAsTimestamp()
deleteGeoLocation(int $a_id)
Example 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.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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.