From 5c7d2e9688d06049982abbe7e55e5a1b2fde3166 Mon Sep 17 00:00:00 2001 From: bison Date: Mon, 22 Aug 2016 13:37:21 +0200 Subject: [PATCH] Changed method getGemeindeByPlz, added DISTINCT and ORDER BY clauses on column ortschaftsname --- application/controllers/api/v1/codex/Gemeinde.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/application/controllers/api/v1/codex/Gemeinde.php b/application/controllers/api/v1/codex/Gemeinde.php index b7ac27653..3be4ecb09 100644 --- a/application/controllers/api/v1/codex/Gemeinde.php +++ b/application/controllers/api/v1/codex/Gemeinde.php @@ -12,7 +12,7 @@ */ // ------------------------------------------------------------------------ -if (!defined('BASEPATH')) exit('No direct script access allowed'); +if (!defined("BASEPATH")) exit("No direct script access allowed"); class Gemeinde extends APIv1_Controller { @@ -23,7 +23,7 @@ class Gemeinde extends APIv1_Controller { parent::__construct(); // Load model GemeindeModel - $this->load->model('codex/gemeinde_model', 'GemeindeModel'); + $this->load->model("codex/gemeinde_model", "GemeindeModel"); } /** @@ -55,7 +55,10 @@ class Gemeinde extends APIv1_Controller if (is_numeric($plz)) { - $result = $this->GemeindeModel->loadWhere(array('plz' => $plz)); + $this->GemeindeModel->addSelect("DISTINCT ON (ortschaftsname) ortschaftsname, gemeinde_id, plz, name, ortschaftskennziffer, bulacode, bulabez, kennziffer"); + $this->GemeindeModel->addOrder("ortschaftsname"); + + $result = $this->GemeindeModel->loadWhere(array("plz" => $plz)); $this->response($result, REST_Controller::HTTP_OK); } @@ -72,9 +75,9 @@ class Gemeinde extends APIv1_Controller { if ($this->_validate($this->post())) { - if (isset($this->post()['gemeinde_id'])) + if (isset($this->post()["gemeinde_id"])) { - $result = $this->GemeindeModel->update($this->post()['gemeinde_id'], $this->post()); + $result = $this->GemeindeModel->update($this->post()["gemeinde_id"], $this->post()); } else {