$id = mysql_insert_id ();
return new feature ($id, $feature->lon, $feature->lat,
$feature->imgpath, $feature->title,
- $feature->description);
+ $feature->description, $feature->date);
}
}
public function getfeature ($id) {
$query = sprintf ("SELECT id, imgpath, title, description, AsText(location)
- AS location FROM %sitems WHERE id = '%s';",
+ AS location, UNIX_TIMESTAMP(date) AS date FROM %sitems
+ WHERE id = '%s';",
$this->dbprefix, mysql_real_escape_string ($id));
$row = mysql_fetch_assoc ($this->_execute_query ($query));
if ($row === false) {
public function listfeatures () {
$query = sprintf ("SELECT id, imgpath, title, description, AsText(location)
- AS location FROM %sitems;",
+ AS location, UNIX_TIMESTAMP(date) AS date FROM %sitems;",
$this->dbprefix);
$features = array ();
return $features;
}
+ public function mostrecentfeatures ($num_features) {
+ $query = sprintf ("SELECT id, imgpath, title, description,
+ AsText(location) AS location, UNIX_TIMESTAMP(date)
+ AS date FROM %sitems ORDER BY date DESC",
+ $this->dbprefix);
+ if ($num_features) {
+ $query .= sprintf (" LIMIT %d", $num_features);
+ }
+ $features = array ();
+ $res = $this->_execute_query ($query);
+ while ($row = mysql_fetch_assoc ($res)) {
+ $feature = $this->_feature_frow_row ($row);
+ if (isset ($feature)) {
+ $features[] = $feature;
+ }
+ }
+ return $features;
+ }
+
public function imgpath_exists ($imgpath) {
$query = sprintf ("SELECT COUNT(*) FROM %sitems WHERE imgpath LIKE '%s';",
$this->dbprefix, mysql_real_escape_string ($imgpath));
$lat = $matches [2];
try {
$feature = new feature ($row ["id"], $lon, $lat, $row ["imgpath"],
- $row ["title"], $row ["description"]);
+ $row ["title"], $row ["description"],
+ $row ["date"]);
} catch (Exception $e) {
return null;
}