added db mapper

This commit is contained in:
Jonas Heinrich 2017-02-16 13:00:43 +01:00
parent 47c5f63c1d
commit 11fc84b0e9
3 changed files with 33 additions and 0 deletions

View File

@ -6,6 +6,7 @@
*/
/** @var $this \OCP\Route\IRouter */
$this->create('radio_index', '/')
->actionInclude('radio/index.php');

23
db/stationmapper.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace OCA\Radio\Db;
use OCP\IDb;
use OCP\AppFramework\Db\Mapper;
class StationMapper extends Mapper {
public function __construct(IDb $db) {
parent::__construct($db, 'radio_stations', '\OCA\Radio\Db\Station');
}
public function find($id, $userId) {
$sql = 'SELECT * FROM *PREFIX*ownnotes_notes WHERE id = ? AND user_id = ?';
return $this->findEntity($sql, [$id, $userId]);
}
public function findAll($userId) {
$sql = 'SELECT * FROM *PREFIX*ownnotes_notes WHERE user_id = ?';
return $this->findEntities($sql, [$userId]);
}
}

View File

@ -43,6 +43,15 @@ $(function(){
}
function get_station_ids(){
$.ajax({
method: "GET",
url: "http://127.0.0.1/index.php/apps/radio/stations",
dataType: 'json',
success: function(data) {
alert(data);
return true;
}
});
return ["89920","44707","91101","85755","45281","78011","91102"]
};