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


PHP Playlist::findOne方法代码示例

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


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

示例1: listened

 /**
  * Adds a playlists to user history
  * increments playlist play count
  * @return [type] [description]
  */
 private function listened()
 {
     Base::requireLogged();
     $ret = array('status' => 0);
     if (empty($_GET['id']) || !Validate::int($_GET['id'])) {
         return $ret;
     }
     $id = (int) $_GET['id'];
     // Checks if the play is unique
     $play = UserListened::where('playlist_id', $id)->where('user_id', LOGGED)->findOne();
     if ($play) {
         return $ret;
     }
     // Adds playlist to user listening history
     $history = UserListened::create();
     $history->user_id = LOGGED;
     $history->playlist_id = $id;
     $history->save();
     // Increment play count
     $playlist = Playlist::findOne($id);
     if (!$playlist) {
         return $ret;
     }
     $playlist->played_count++;
     $playlist->save();
     // Everything went right
     $ret['status'] = 1;
     return $ret;
 }
开发者ID:nytr0gen,项目名称:plur-music-explorer,代码行数:34,代码来源:request.php

示例2: __construct

 function __construct()
 {
     if (FIRST_PARAMETER === 'playlist' && SECOND_PARAMETER === 'new') {
         $this->newPlaylist();
     }
     if (!FIRST_PARAMETER || !Validate::id(FIRST_PARAMETER)) {
         Base::redirect('/oops');
     }
     $this->playlist = Playlist::findOne((int) FIRST_PARAMETER);
     if (!$this->playlist) {
         Base::redirect('/oops');
     }
     // Title
     View::set('page_title', $this->playlist->title);
     // Playlist not published
     if (!$this->playlist->published) {
         if (!LOGGED) {
             // Not logged
             Base::requireLogged();
         } else {
             if (LOGGED !== $this->playlist->user_id) {
                 // User not author
                 Base::requireAdmin();
             }
         }
     }
     if (!SECOND_PARAMETER) {
         $this->playlist();
     } else {
         if (ctype_lower(SECOND_PARAMETER) && method_exists($this, SECOND_PARAMETER)) {
             $func = SECOND_PARAMETER;
             $this->{$func}();
         } else {
             Base::redirect('/oops');
         }
     }
 }
开发者ID:nytr0gen,项目名称:plur-music-explorer,代码行数:37,代码来源:playlist.php


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