add placeinfo and map
This commit is contained in:
parent
b659857f03
commit
1d0695f223
@ -10,10 +10,12 @@ require_once UELEARNING_LIB_ROOT.'/Study/StudyActivityManager.php';
|
||||
require_once UELEARNING_LIB_ROOT.'/Study/StudyManager.php';
|
||||
require_once UELEARNING_LIB_ROOT.'/Target/Target.php';
|
||||
require_once UELEARNING_LIB_ROOT.'/Target/TargetManager.php';
|
||||
require_once UELEARNING_LIB_ROOT.'/Database/DBInfo.php';
|
||||
use UElearning\User;
|
||||
use UElearning\Study;
|
||||
use UElearning\Target;
|
||||
use UElearning\Exception;
|
||||
use UElearning\Database;
|
||||
|
||||
$app = new \Slim\Slim(array(
|
||||
'templates.path' => './', // 設定Path
|
||||
@ -1239,6 +1241,26 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) {
|
||||
|
||||
// ============================================================================
|
||||
|
||||
/*
|
||||
* 推薦學習點
|
||||
* GET http://localhost/api/v2/info
|
||||
*/
|
||||
$app->get('/info', 'APIrequest', function () use ($app) {
|
||||
|
||||
$db = new Database\DBInfo();
|
||||
$placeInfoResult = $db->queryAllPlaceInfo();
|
||||
$placeMapResult = $db->queryALLPlaceMap();
|
||||
|
||||
// 噴出結果
|
||||
$app->render(200,array(
|
||||
'place_info' => $placeInfoResult,
|
||||
'place_map' => $placeMapResult,
|
||||
'error' => false
|
||||
));
|
||||
});
|
||||
|
||||
// ============================================================================
|
||||
|
||||
// 取得Client要求的格式
|
||||
$requestType = $app->request->headers->get('Accept');
|
||||
// 若要求網頁版
|
||||
|
85
htdocs/lib/Database/DBInfo.php
Normal file
85
htdocs/lib/Database/DBInfo.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* DBTarget.php
|
||||
*
|
||||
* 此檔案針對學習標的,以及學習標的的區域、廳等的資料庫查詢用。
|
||||
*/
|
||||
|
||||
namespace UElearning\Database;
|
||||
|
||||
use UElearning\Exception;
|
||||
|
||||
require_once UELEARNING_LIB_ROOT.'/Database/Database.php';
|
||||
require_once UELEARNING_LIB_ROOT.'/Database/Exception.php';
|
||||
|
||||
/**
|
||||
* 學習標的資料表
|
||||
*
|
||||
* 此檔案針對學習標的,以及學習標的的區域、廳等的資料表進行操作。
|
||||
*
|
||||
*
|
||||
* @author Yuan Chiu <chyuaner@gmail.com>
|
||||
* @version 2.0.0
|
||||
* @package UElearning
|
||||
* @subpackage Database
|
||||
*/
|
||||
class DBInfo extends Database {
|
||||
|
||||
public function queryAllPlaceInfo() {
|
||||
$sqlString = "SELECT * FROM `".$this->table('PlaceInfo')."` WHERE 1";
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->execute();
|
||||
|
||||
$queryResultAll = $query->fetchAll();
|
||||
|
||||
// return $queryResultAll;
|
||||
|
||||
// 如果有查到一筆以上
|
||||
if( count($queryResultAll) >= 1 ) {
|
||||
// 製作回傳結果陣列
|
||||
$result = array();
|
||||
foreach($queryResultAll as $key => $thisResult) {
|
||||
|
||||
array_push($result,
|
||||
array( 'id' => $thisResult['IID'],
|
||||
'name' => $thisResult['IName'],
|
||||
'content' => $thisResult['IContent']
|
||||
));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
// 若都沒查到的話
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public function queryALLPlaceMap() {
|
||||
$sqlString = "SELECT * FROM `".$this->table('PlaceMap')."` WHERE 1";
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->execute();
|
||||
|
||||
$queryResultAll = $query->fetchAll();
|
||||
|
||||
// 如果有查到一筆以上
|
||||
if( count($queryResultAll) >= 1 ) {
|
||||
// 製作回傳結果陣列
|
||||
$result = array();
|
||||
foreach($queryResultAll as $key => $thisResult) {
|
||||
|
||||
array_push($result,
|
||||
array( 'id' => $thisResult['PID'],
|
||||
'name' => $thisResult['PName'],
|
||||
'url' => $thisResult['PURL']
|
||||
));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
// 若都沒查到的話
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user