本文整理汇总了PHP中Stats::get_object_count方法的典型用法代码示例。如果您正苦于以下问题:PHP Stats::get_object_count方法的具体用法?PHP Stats::get_object_count怎么用?PHP Stats::get_object_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stats
的用法示例。
在下文中一共展示了Stats::get_object_count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _get_extra_info
/**
* _get_extra info
* This returns the extra information for the artist, this means totals etc
*/
private function _get_extra_info($catalog = FALSE)
{
// Try to find it in the cache and save ourselves the trouble
if (parent::is_cached('artist_extra', $this->id)) {
$row = parent::get_from_cache('artist_extra', $this->id);
} else {
$uid = Dba::escape($this->id);
$sql = "SELECT `song`.`artist`,COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " . "WHERE `song`.`artist`='{$uid}' ";
if ($catalog) {
$sql .= "AND (`song`.`catalog` = '{$catalog}') ";
}
if (AmpConfig::get('catalog_disable')) {
$sql .= " AND `catalog`.`enabled` = '1'";
}
$sql .= "GROUP BY `song`.`artist`";
$db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results);
if (AmpConfig::get('show_played_times')) {
$row['object_cnt'] = Stats::get_object_count('artist', $row['artist']);
}
parent::add_to_cache('artist_extra', $row['artist'], $row);
}
/* Set Object Vars */
$this->songs = $row['song_count'];
$this->albums = $row['album_count'];
$this->time = $row['time'];
return $row;
}
示例2: _get_extra_info
/**
* _get_extra info
* This returns the extra information for the artist, this means totals etc
* @param int $catalog
* @return array
*/
private function _get_extra_info($catalog = 0, $limit_threshold = '')
{
// Try to find it in the cache and save ourselves the trouble
if (parent::is_cached('artist_extra', $this->id)) {
$row = parent::get_from_cache('artist_extra', $this->id);
} else {
$params = array($this->id);
// Calculation
$sql = "SELECT COUNT(DISTINCT `song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
$sqlw = "WHERE `song`.`artist` = ? ";
if ($catalog) {
$params[] = $catalog;
$sqlw .= "AND (`song`.`catalog` = ?) ";
}
if (AmpConfig::get('catalog_disable')) {
$sqlw .= " AND `catalog`.`enabled` = '1' ";
}
$sql .= $sqlw . "GROUP BY `song`.`artist`";
$db_results = Dba::read($sql, $params);
$row = Dba::fetch_assoc($db_results);
// Get associated information from first song only
$sql = "SELECT `song`.`artist`, `song`.`catalog` as `catalog_id` FROM `song` LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
$sql .= $sqlw . "LIMIT 1";
$db_results = Dba::read($sql, $params);
$row = array_merge($row, Dba::fetch_assoc($db_results));
if (AmpConfig::get('show_played_times')) {
$row['object_cnt'] = Stats::get_object_count('artist', $row['artist'], $limit_threshold);
}
parent::add_to_cache('artist_extra', $row['artist'], $row);
}
/* Set Object Vars */
$this->songs = $row['song_count'];
$this->albums = $row['album_count'];
$this->time = $row['time'];
$this->catalog_id = $row['catalog_id'];
return $row;
}
示例3: _get_extra_info
/**
* _get_extra_info
* This pulls the extra information from our tables, this is a 3 table join, which is why we don't normally
* do it
*/
private function _get_extra_info()
{
if (parent::is_cached('album_extra', $this->id)) {
return parent::get_from_cache('album_extra', $this->id);
}
$sql = "SELECT " . "COUNT(DISTINCT(`song`.`artist`)) AS `artist_count`, " . "COUNT(`song`.`id`) AS `song_count`, " . "SUM(`song`.`time`) as `total_duration`," . "`song`.`catalog` as `catalog_id`," . "`artist`.`name` AS `artist_name`, " . "`artist`.`prefix` AS `artist_prefix`, " . "`artist`.`id` AS `artist_id` " . "FROM `song` INNER JOIN `artist` " . "ON `artist`.`id`=`song`.`artist` ";
if (AmpConfig::get('catalog_disable')) {
$sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
}
$suite_array = array();
if ($this->allow_group_disks) {
$suite_array = $this->album_suite;
}
if (!count($suite_array)) {
$suite_array[] = $this->id;
}
$idlist = '(' . implode(',', $suite_array) . ')';
$sql .= "WHERE `song`.`album` IN {$idlist} ";
if (AmpConfig::get('catalog_disable')) {
$sql .= "AND `catalog`.`enabled` = '1' ";
}
if (!count($this->album_suite)) {
$sql .= "GROUP BY `song`.`album`";
} else {
$sql .= "GROUP BY `song`.`artist`";
}
$db_results = Dba::read($sql);
$results = Dba::fetch_assoc($db_results);
$art = new Art($this->id, 'album');
$art->get_db();
$results['has_art'] = make_bool($art->raw);
$results['has_thumb'] = make_bool($art->thumb);
if (AmpConfig::get('show_played_times')) {
$results['object_cnt'] = Stats::get_object_count('album', $this->id);
}
parent::add_to_cache('album_extra', $this->id, $results);
return $results;
}
示例4: _get_info
/**
* _get_info
* @return array|boolean
*/
private function _get_info($limit_threshold = '')
{
$id = $this->id;
if (parent::is_cached('song', $id)) {
return parent::get_from_cache('song', $id);
}
$sql = 'SELECT `song`.`id`, `song`.`file`, `song`.`catalog`, `song`.`album`, `album`.`album_artist` AS `albumartist`, `song`.`year`, `song`.`artist`,' . '`song`.`title`, `song`.`bitrate`, `song`.`rate`, `song`.`mode`, `song`.`size`, `song`.`time`, `song`.`track`, ' . '`song`.`played`, `song`.`enabled`, `song`.`update_time`, `song`.`mbid`, `song`.`addition_time`, `song`.`license`, ' . '`song`.`composer`, `song`.`user_upload`, `album`.`mbid` AS `album_mbid`, `artist`.`mbid` AS `artist_mbid`, `album_artist`.`mbid` AS `albumartist_mbid` ' . 'FROM `song` LEFT JOIN `album` ON `album`.`id` = `song`.`album` LEFT JOIN `artist` ON `artist`.`id` = `song`.`artist` ' . 'LEFT JOIN `artist` AS `album_artist` ON `album_artist`.`id` = `album`.`album_artist` ' . 'WHERE `song`.`id` = ?';
$db_results = Dba::read($sql, array($id));
$results = Dba::fetch_assoc($db_results);
if (isset($results['id'])) {
if (AmpConfig::get('show_played_times')) {
$results['object_cnt'] = Stats::get_object_count('song', $results['id'], $limit_threshold);
}
parent::add_to_cache('song', $id, $results);
return $results;
}
return false;
}