From baffbd6dcfb0f52ce77c510320c55590fbaa4644 Mon Sep 17 00:00:00 2001 From: kobayashi <3011850@gmail.com> Date: Sat, 27 Dec 2014 03:09:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90queryBelongByWhere=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/lib/Database/DBRecommand.php | 36 ++++++++++++++++++++----- htdocs/lib/Recommand/RecommandPoint.php | 6 +++-- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/htdocs/lib/Database/DBRecommand.php b/htdocs/lib/Database/DBRecommand.php index 3efbaf1..c2b8003 100644 --- a/htdocs/lib/Database/DBRecommand.php +++ b/htdocs/lib/Database/DBRecommand.php @@ -9,13 +9,35 @@ require_once UELEARNING_LIB_ROOT.'/Database/Exception.php'; class DBRecomamnd extends Database { - public function __construct() - { - - } - + + /** + * 內部查詢用 + * @param string $where SQL WHERE子句 + * @return array 查詢結果 + */ protected function queryBelongByWhere($where) { - + $sqlString = "SELECT DISTINCT ".$this->table('Edge').".Ti, ".$this->table('Edge').".Tj, ".$this->table('Edge').".MoveTime". + " FROM ".$this->table('Edge')." WHERE ".$where; + $this->conndb->prepare($sqlString); + $this->conndb->execute(); + + $queryAllResult = $this->conndb->fetchAll(); + + if(count($queryAllResult) != 0) + { + $result = array(); + foreach ($queryAllResult as $key => $thisResult) + { + array_push($result, + array("Ti" => $thisResult['Ti'], + "Tj" => $thisResult['Tj'], + "MoveTime" => $thisResult['MoveTime'])); + } + + return $result; + } + else return null; } -} \ No newline at end of file + +} diff --git a/htdocs/lib/Recommand/RecommandPoint.php b/htdocs/lib/Recommand/RecommandPoint.php index b896bb6..0e297c7 100644 --- a/htdocs/lib/Recommand/RecommandPoint.php +++ b/htdocs/lib/Recommand/RecommandPoint.php @@ -28,6 +28,8 @@ class RecommandPoint * @type double */ private const $ALPHA = 0.5; + + private public function __construct() @@ -41,14 +43,14 @@ class RecommandPoint */ private function computeNormalizationParameter() { - + $ } /** * 推薦學習點 * @return array 學習點清單 */ - public function recommand() + public function recommand($ ) { }