@@ -23,7 +23,7 @@ class FieldtypeLeafletMapMarker extends Fieldtype {
2323 public static function getModuleInfo() {
2424 return array(
2525 'title' => 'Leaflet Map Marker',
26- 'version' => '3.0.2 ',
26+ 'version' => '3.0.3 ',
2727 'summary' => 'Field that stores an address with latitude and longitude coordinates and has built-in geocoding capability with Leaflet Maps API.',
2828 'installs' => 'InputfieldLeafletMapMarker',
2929 'icon' => 'map-marker',
@@ -103,6 +103,7 @@ class FieldtypeLeafletMapMarker extends Fieldtype {
103103 $marker->lng = $value['lng'];
104104 $marker->status = $value['status'];
105105 $marker->zoom = $value['zoom'];
106+ $marker->raw = $value['raw'];
106107 // $marker->provider = $value['provider'];
107108 $marker->setTrackChanges(true);
108109
@@ -133,7 +134,8 @@ class FieldtypeLeafletMapMarker extends Fieldtype {
133134 'lat' => strlen($marker->lat) ? $marker->lat : 0,
134135 'lng' => strlen($marker->lng) ? $marker->lng : 0,
135136 'status' => $marker->status,
136- 'zoom' => $marker->zoom/*,
137+ 'zoom' => $marker->zoom,
138+ 'raw' => $marker->raw/*,
137139 'provider' => $marker->provider*/
138140 );
139141
@@ -155,6 +157,7 @@ class FieldtypeLeafletMapMarker extends Fieldtype {
155157 $schema['lng'] = "FLOAT(10,6) NOT NULL DEFAULT 0"; // longitude
156158 $schema['status'] = "TINYINT NOT NULL DEFAULT 0"; // geocode status
157159 $schema['zoom'] = "TINYINT NOT NULL DEFAULT 0"; // zoom level (schema v1)
160+ $schema['raw'] = "TEXT NOT NULL DEFAULT ''"; // raw google geocode data
158161 // $schema['provider'] = "VARCHAR(255) NOT NULL DEFAULT ''";
159162
160163 $schema['keys']['latlng'] = "KEY latlng (lat, lng)"; // keep an index of lat/lng
@@ -201,6 +204,28 @@ class FieldtypeLeafletMapMarker extends Fieldtype {
201204 }
202205 }
203206 }
207+
208+ //PDO update by Patman15
209+ if($schemaVersion == 1) {
210+ // update schema to v2: add 'raw' column
211+ $schemaVersion = 2;
212+ $database = $this->wire('database');
213+ $table = $database->escapeTable($field->getTable());
214+ $query = $database->prepare("SHOW TABLES LIKE '$table'");
215+ $query->execute();
216+ $row = $query->fetch(\PDO::FETCH_NUM);
217+ $query->closeCursor();
218+ if(!empty($row)) {
219+ $query = $database->prepare("SHOW COLUMNS FROM `$table` WHERE field='raw'");
220+ $query->execute();
221+ if(!$query->rowCount()) try {
222+ $database->exec("ALTER TABLE `$table` ADD raw $schema[raw] AFTER zoom");
223+ $this->message("Added 'raw' column to '$field->table'");
224+ } catch(Exception $e) {
225+ $this->error($e->getMessage());
226+ }
227+ }
228+ }
204229
205230 $field->set('schemaVersion', $schemaVersion);
206231 $field->save();
0 commit comments