- $query = sprintf ("SELECT imgurl FROM %sitems WHERE imgurl = '%s'",
- $this->dbprefix,
- mysql_real_escape_string ($feature->imgurl));
- $this->_execute_query ($query);
- if (mysql_affected_rows ($this->link) == 0) {
- if ($feature->imgurl_exists ()) {
+ try {
+ $id = $feature->id;
+ } catch (Exception $e) {}
+ if (isset ($id)) {
+ $query = sprintf ("UPDATE %sitems SET
+ imgpath='%s',
+ title='%s',
+ description='%s',
+ location=GeomFromText('POINT(%s %s)')
+ WHERE id = '%s';",
+ $this->dbprefix,
+ mysql_real_escape_string ($feature->imgpath),
+ mysql_real_escape_string ($feature->title),
+ mysql_real_escape_string ($feature->description),
+ $feature->lon,
+ $feature->lat,
+ $id);
+ $this->_execute_query ($query);
+ return $feature;
+ } else {