当前位置: 首页>>代码示例>>PHP>>正文


PHP Flight::mdb方法代码示例

本文整理汇总了PHP中Flight::mdb方法的典型用法代码示例。如果您正苦于以下问题:PHP Flight::mdb方法的具体用法?PHP Flight::mdb怎么用?PHP Flight::mdb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Flight的用法示例。


在下文中一共展示了Flight::mdb方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: recommended

 public static function recommended()
 {
     $dbname = 'predictionio_appdata';
     $mdb = Flight::mdb();
     $db = $mdb->{$dbname};
     $items = $db->items;
     $client = Flight::prediction_client();
     $recommended_movies = array();
     try {
         $user_id = $_SESSION['user_id'];
         $client->identify($user_id);
         $command = $client->getCommand('itemrec_get_top_n', array('pio_engine' => 'movie-recommender', 'pio_n' => 9));
         $recommended_movies_raw = $client->execute($command);
         $movie_iids = $recommended_movies_raw['pio_iids'];
         array_walk($movie_iids, function (&$movie_iid) {
             $movie_iid = '4_' . $movie_iid;
         });
         $cursor = $items->find(array('itypes' => '1', '_id' => array('$in' => $movie_iids)));
         $recommended_movies = array_values(iterator_to_array($cursor));
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
     $_SESSION['movies_viewed'] = 0;
     $_SESSION['user_id'] = '';
     Flight::render('recommended', array('recommended_movies' => $recommended_movies), 'content');
     Flight::render('layout', array('title' => 'Recommended', 'base_path' => '/movie_recommender'));
 }
开发者ID:ChenOhayon,项目名称:sitepoint_codes,代码行数:27,代码来源:home.php

示例2: recommended

 public static function recommended()
 {
     $dbname = 'predictionio_appdata';
     $mdb = Flight::mdb();
     $db = $mdb->{$dbname};
     $items = $db->items;
     $client = Flight::prediction_client();
     $recommended_movies = array();
     try {
         $user_id = $_SESSION['user_id'];
         $client = new EngineClient('http://localhost:8000');
         $recommended_movies_raw = $client->sendQuery(array('user' => $user_id, 'num' => 9));
         $movie_iids = array_map(function ($item) {
             return $item['item'];
         }, $recommended_movies_raw['itemScores']);
         $cursor = $items->find(array('itypes' => '1', '_id' => array('$in' => $movie_iids)));
         $recommended_movies = array_values(iterator_to_array($cursor));
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
     $_SESSION['movies_viewed'] = 0;
     $_SESSION['user_id'] = '';
     Flight::render('recommended', array('recommended_movies' => $recommended_movies), 'content');
     Flight::render('layout', array('title' => 'Recommended', 'base_path' => '/movie_recommender'));
 }
开发者ID:superboybmt,项目名称:sitepoint_codes,代码行数:25,代码来源:home.php


注:本文中的Flight::mdb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。