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


PHP Dba::fetch_row方法代码示例

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


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

示例1: get_allowed_bitrate

 /**
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public static function get_allowed_bitrate($song)
 {
     $max_bitrate = AmpConfig::get('max_bit_rate');
     $min_bitrate = AmpConfig::get('min_bit_rate');
     // FIXME: This should be configurable for each output type
     $user_sample_rate = AmpConfig::get('sample_rate');
     // If the user's crazy, that's no skin off our back
     if ($user_sample_rate < $min_bitrate) {
         $min_bitrate = $user_sample_rate;
     }
     // Are there site-wide constraints? (Dynamic downsampling.)
     if ($max_bitrate > 1) {
         $sql = 'SELECT COUNT(*) FROM `now_playing` ' . 'WHERE `user` IN ' . '(SELECT DISTINCT `user_preference`.`user` ' . 'FROM `preference` JOIN `user_preference` ' . 'ON `preference`.`id` = ' . '`user_preference`.`preference` ' . "WHERE `preference`.`name` = 'play_type' " . "AND `user_preference`.`value` = 'downsample')";
         $db_results = Dba::read($sql);
         $results = Dba::fetch_row($db_results);
         $active_streams = intval($results[0]) ?: 0;
         debug_event('stream', 'Active transcoding streams: ' . $active_streams, 5);
         // We count as one for the algorithm
         // FIXME: Should this reflect the actual bit rates?
         $active_streams++;
         $sample_rate = floor($max_bitrate / $active_streams);
         // Exit if this would be insane
         if ($sample_rate < ($min_bitrate ?: 8)) {
             debug_event('stream', 'Max transcode bandwidth already allocated. Active streams: ' . $active_streams, 2);
             header('HTTP/1.1 503 Service Temporarily Unavailable');
             exit;
         }
         // Never go over the user's sample rate
         if ($sample_rate > $user_sample_rate) {
             $sample_rate = $user_sample_rate;
         }
     } else {
         $sample_rate = $user_sample_rate;
     }
     return $sample_rate;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:40,代码来源:stream.class.php

示例2: gc

 /**
  * gc
  * This cleans up art that no longer has a corresponding object
  */
 public static function gc($object_type = null, $object_id = null)
 {
     $types = array('album', 'artist', 'tvshow', 'tvshow_season', 'video', 'user');
     if ($object_type != null) {
         if (in_array($object_type, $types)) {
             if (AmpConfig::get('album_art_store_disk')) {
                 self::delete_from_dir($object_type, $object_id);
             }
             $sql = "DELETE FROM `image` WHERE `object_type` = ? AND `object_id` = ?";
             Dba::write($sql, array($object_type, $object_id));
         } else {
             debug_event('art', 'Garbage collect on type `' . $object_type . '` is not supported.', 1);
         }
     } else {
         // iterate over our types and delete the images
         foreach ($types as $type) {
             if (AmpConfig::get('album_art_store_disk')) {
                 $sql = "SELECT `image`.`object_id`, `image`.`object_type` FROM `image` LEFT JOIN `" . $type . "` ON `" . $type . "`.`id`=" . "`image`.`object_id` WHERE `object_type`='" . $type . "' AND `" . $type . "`.`id` IS NULL";
                 $db_results = Dba::read($sql);
                 while ($row = Dba::fetch_row($db_results)) {
                     self::delete_from_dir($row[1], $row[0]);
                 }
             }
             $sql = "DELETE FROM `image` USING `image` LEFT JOIN `" . $type . "` ON `" . $type . "`.`id`=" . "`image`.`object_id` WHERE `object_type`='" . $type . "' AND `" . $type . "`.`id` IS NULL";
             Dba::write($sql);
         }
         // foreach
     }
 }
开发者ID:cheese1,项目名称:ampache,代码行数:33,代码来源:art.class.php

示例3: optimize_tables

 /**
  * optimize_tables
  *
  * This runs an optimize on the tables and updates the stats to improve
  * join speed.
  * This can be slow, but is a good idea to do from time to time. We do
  * it in case the dba isn't doing it... which we're going to assume they
  * aren't.
  */
 public static function optimize_tables()
 {
     $sql = "SHOW TABLES";
     $db_results = Dba::read($sql);
     while ($row = Dba::fetch_row($db_results)) {
         $sql = "OPTIMIZE TABLE `" . $row[0] . "`";
         Dba::write($sql);
         $sql = "ANALYZE TABLE `" . $row[0] . "`";
         Dba::write($sql);
     }
 }
开发者ID:cheese1,项目名称:ampache,代码行数:20,代码来源:dba.class.php

示例4: count_items

 /**
  * count_items
  * This returns a count of the total number of tracks that are in this
  * tmp playlist
  */
 public function count_items()
 {
     $id = Dba::escape($this->id);
     $sql = "SELECT COUNT(`id`) FROM `tmp_playlist_data` WHERE " . "`tmp_playlist`='{$id}'";
     $db_results = Dba::read($sql);
     $results = Dba::fetch_row($db_results);
     return $results['0'];
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:13,代码来源:tmp_playlist.class.php

示例5: check_local_mp3

 /**
  * check_local_mp3
  * Checks the song to see if it's there already returns true if found, false if not
  */
 public function check_local_mp3($full_file, $gather_type = '')
 {
     $file_date = filemtime($full_file);
     if ($file_date < $this->last_add) {
         debug_event('Check', 'Skipping ' . $full_file . ' File modify time before last add run', '3');
         return true;
     }
     $sql = "SELECT `id` FROM `song` WHERE `file` = ?";
     $db_results = Dba::read($sql, array($full_file));
     //If it's found then return true
     if (Dba::fetch_row($db_results)) {
         return true;
     }
     return false;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:19,代码来源:local.catalog.php

示例6: check_network

 /**
  * check_network
  *
  * This takes a type, ip, user, level and key and then returns whether they
  * are allowed. The IP is passed as a dotted quad.
  */
 public static function check_network($type, $user, $level, $ip = null)
 {
     if (!AmpConfig::get('access_control')) {
         switch ($type) {
             case 'interface':
             case 'stream':
                 return true;
             default:
                 return false;
         }
     }
     // Clean incoming variables
     $ip = $ip ?: $_SERVER['REMOTE_ADDR'];
     $ip = inet_pton($ip);
     switch ($type) {
         case 'init-api':
             if ($user) {
                 $user = User::get_from_username($user);
                 $user = $user->id;
             }
         case 'api':
             $type = 'rpc';
         case 'network':
         case 'interface':
         case 'stream':
             break;
         default:
             return false;
     }
     // end switch on type
     $sql = 'SELECT `id` FROM `access_list` ' . 'WHERE `start` <= ? AND `end` >= ? ' . 'AND `level` >= ? AND `type` = ?';
     $params = array($ip, $ip, $level, $type);
     if (strlen($user) && $user != '-1') {
         $sql .= " AND `user` IN(?, '-1')";
         $params[] = $user;
     } else {
         $sql .= " AND `user` = '-1'";
     }
     $db_results = Dba::read($sql, $params);
     if (Dba::fetch_row($db_results)) {
         // Yah they have access they can use the mojo
         return true;
     }
     return false;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:51,代码来源:access.class.php

示例7: count

 /**
  * count
  *
  * This returns the number of user accounts that exist.
  */
 public static function count()
 {
     $sql = 'SELECT COUNT(`id`) FROM `user`';
     $db_results = Dba::read($sql);
     $data = Dba::fetch_row($db_results);
     $results = array();
     $results['users'] = $data[0];
     $time = time();
     $last_seen = $time - 1200;
     $sql = 'SELECT COUNT(DISTINCT `session`.`username`) FROM `session` ' . 'INNER JOIN `user` ON `session`.`username` = `user`.`username` ' . 'WHERE `session`.`expire` > ? and `user`.`last_seen` > ?';
     $db_results = Dba::read($sql, array($time, $last_seen));
     $data = Dba::fetch_row($db_results);
     $results['connected'] = $data[0];
     return $results;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:20,代码来源:user.class.php

示例8: get_total_duration

 /**
  * get_total_duration
  * Get the total duration of all songs.
  */
 public function get_total_duration()
 {
     $songs = self::get_songs();
     $idlist = '(' . implode(',', $songs) . ')';
     $sql = "SELECT SUM(`time`) FROM `song` WHERE `id` IN {$idlist}";
     $db_results = Dba::read($sql);
     $results = Dba::fetch_row($db_results);
     return $results['0'];
 }
开发者ID:nioc,项目名称:ampache,代码行数:13,代码来源:playlist.class.php

示例9: get_newest

 /**
  * get_newest
  * This returns an array of the newest artists/albums/whatever
  * in this ampache instance
  */
 public static function get_newest($type, $count = '', $offset = '', $catalog = 0)
 {
     if (!$count) {
         $count = AmpConfig::get('popular_threshold');
     }
     if (!$offset) {
         $limit = $count;
     } else {
         $limit = $offset . ',' . $count;
     }
     $sql = self::get_newest_sql($type, $catalog);
     $sql .= "LIMIT {$limit}";
     $db_results = Dba::read($sql);
     $items = array();
     while ($row = Dba::fetch_row($db_results)) {
         $items[] = $row[0];
     }
     // end while results
     return $items;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:25,代码来源:stats.class.php

示例10: count_songs

 /**
  * count_songs
  *
  * This returns the current number of songs, albums, and artists
  * in this catalog.
  */
 public static function count_songs($id = null)
 {
     $where_sql = $id ? 'WHERE `catalog` = ?' : '';
     $params = $id ? array($id) : null;
     $sql = 'SELECT COUNT(`id`), SUM(`time`), SUM(`size`) FROM `song` ' . $where_sql;
     $db_results = Dba::read($sql, $params);
     $data = Dba::fetch_row($db_results);
     $songs = $data[0];
     $time = $data[1];
     $size = $data[2];
     $sql = 'SELECT COUNT(DISTINCT(`album`)) FROM `song` ' . $where_sql;
     $db_results = Dba::read($sql, $params);
     $data = Dba::fetch_row($db_results);
     $albums = $data[0];
     $sql = 'SELECT COUNT(DISTINCT(`artist`)) FROM `song` ' . $where_sql;
     $db_results = Dba::read($sql, $params);
     $data = Dba::fetch_row($db_results);
     $artists = $data[0];
     $results = array();
     $results['songs'] = $songs;
     $results['albums'] = $albums;
     $results['artists'] = $artists;
     $results['size'] = $size;
     $results['time'] = $time;
     return $results;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:32,代码来源:catalog.class.php

示例11: get_videos_count

 /**
  *
  * @param int|null $catalog_id
  * @param string $type
  * @return int
  */
 public static function get_videos_count($catalog_id = null, $type = '')
 {
     $sql = "SELECT COUNT(`video`.`id`) AS `video_cnt` FROM `video` ";
     if (!empty($type)) {
         $sql .= "JOIN `" . $type . "` ON `" . $type . "`.`id` = `video`.`id` ";
     }
     if ($catalog_id) {
         $sql .= "WHERE `video`.`catalog` = `" . intval($catalog_id) . "`";
     }
     $db_results = Dba::read($sql);
     $video_cnt = 0;
     if ($row = Dba::fetch_row($db_results)) {
         $video_cnt = $row[0];
     }
     return $video_cnt;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:22,代码来源:catalog.class.php

示例12: get_random_songs

 /**
  * get_random_songs
  * gets a random number, and a random assortment of songs from this album
  */
 public function get_random_songs()
 {
     $sql = "SELECT `song`.`id` FROM `song` ";
     if (AmpConfig::get('catalog_disable')) {
         $sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
     }
     $sql .= "WHERE `song`.`album` = ? ";
     if (AmpConfig::get('catalog_disable')) {
         $sql .= "AND `catalog`.`enabled` = '1' ";
     }
     $sql .= "ORDER BY RAND()";
     $db_results = Dba::read($sql, array($this->id));
     $results = array();
     while ($r = Dba::fetch_row($db_results)) {
         $results[] = $r['0'];
     }
     return $results;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:22,代码来源:album.class.php

示例13: add_episodes

 public function add_episodes($episodes, $afterdate = 0, $gather = false)
 {
     foreach ($episodes as $episode) {
         $this->add_episode($episode, $afterdate);
     }
     // Select episodes to download
     $dlnb = AmpConfig::get('podcast_new_download');
     if ($dlnb != 0) {
         $sql = "SELECT `podcast_episode`.`id` FROM `podcast_episode` INNER JOIN `podcast` ON `podcast`.`id` = `podcast_episode`.`podcast` " . "WHERE `podcast`.`id` = ? AND `podcast_episode`.`addition_time` > `podcast`.`lastsync` " . "ORDER BY `podcast_episode`.`pubdate` DESC";
         if ($dlnb != -1) {
             $sql .= " LIMIT " . $dlnb;
         }
         $db_results = Dba::read($sql, array($this->id));
         while ($row = Dba::fetch_row($db_results)) {
             $episode = new Podcast_Episode($row[0]);
             $episode->change_state('pending');
             if ($gather) {
                 $episode->gather();
             }
         }
     }
     // Remove items outside limit
     $keepnb = AmpConfig::get('podcast_keep');
     if ($keepnb > 0) {
         $sql = "SELECT `podcast_episode`.`id` FROM `podcast_episode` WHERE `podcast_episode`.`podcast` = ? " . "ORDER BY `podcast_episode`.`pubdate` DESC LIMIT " . $keepnb . ",18446744073709551615";
         $db_results = Dba::read($sql, array($this->id));
         while ($row = Dba::fetch_row($db_results)) {
             $episode = new Podcast_Episode($row[0]);
             $episode->remove();
         }
     }
     $this->update_lastsync(time());
 }
开发者ID:bl00m,项目名称:ampache,代码行数:33,代码来源:podcast.class.php


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