diff --git a/controller/citycontroller.php b/controller/citycontroller.php index 0b6c163..91b4c23 100644 --- a/controller/citycontroller.php +++ b/controller/citycontroller.php @@ -17,7 +17,9 @@ use \OCP\AppFramework\Controller; use \OCP\AppFramework\Http\JSONResponse; use \OCP\AppFramework\Http; +use \OCA\Weather\Db\CityEntity; use \OCA\Weather\Db\CityMapper; +use \OCA\Weather\Db\SettingsMapper; use \OCA\Weather\Controller\IntermediateController; class CityController extends IntermediateController { @@ -101,7 +103,11 @@ class CityController extends IntermediateController { return new JSONResponse(array(), 403); } - $this->mapper->delete($id); + $entity = new CityEntity(); + $entity->setId($id); + $entity->setUser_id($this->userId); + + $this->mapper->delete($entity); return new JSONResponse(array("deleted" => true)); } diff --git a/db/cityentity.php b/db/cityentity.php new file mode 100644 index 0000000..bd9714c --- /dev/null +++ b/db/cityentity.php @@ -0,0 +1,27 @@ + + * @copyright Loic Blot 2015 + */ + +namespace OCA\Weather\Db; + +use \OCP\AppFramework\Db\Entity; + +class CityEntity extends Entity { + public $id; + public $name; + public $user_id; + + public function __construct() { + $this->addType('id', 'integer'); + $this->addType('user_id', 'integer'); + } +} + +?> diff --git a/db/citymapper.php b/db/citymapper.php index 3147c82..70b4080 100644 --- a/db/citymapper.php +++ b/db/citymapper.php @@ -66,13 +66,5 @@ class CityMapper extends Mapper { } return null; } - - public function delete ($id) { - \OCP\DB::beginTransaction(); - $query = \OCP\DB::prepare('DELETE FROM *PREFIX*weather_city ' . - 'WHERE id = ?'); - $query->execute(array($id)); - \OCP\DB::commit(); - } }; ?>