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


PHP Artist::construct_from_array方法代码示例

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


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

示例1: get_artists

 /**
  * get_artist
  *
  * This returns an array of ids of artists that have songs in the catalogs parameter
  */
 public static function get_artists($catalogs = null)
 {
     $sql_where = "";
     if (is_array($catalogs) && count($catalogs)) {
         $catlist = '(' . implode(',', $catalogs) . ')';
         $sql_where = "WHERE `song`.`catalog` IN {$catlist}";
     }
     $sql = "SELECT `artist`.id, `artist`.`name`, `artist`.`summary` FROM `song` LEFT JOIN `artist` ON `artist`.`id` = `song`.`artist` {$sql_where} GROUP BY `song`.artist ORDER BY `artist`.`name`";
     $results = array();
     $db_results = Dba::read($sql);
     while ($r = Dba::fetch_assoc($db_results)) {
         $results[] = Artist::construct_from_array($r);
     }
     return $results;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:20,代码来源:catalog.class.php

示例2: get_artists

 /**
  * get_artists
  *
  * This returns an array of artists that have songs in the catalogs parameter
  * @param array|null $catalogs
  * @return \Artist[]
  */
 public static function get_artists($catalogs = null, $size = 0, $offset = 0)
 {
     $sql_where = "";
     if (is_array($catalogs) && count($catalogs)) {
         $catlist = '(' . implode(',', $catalogs) . ')';
         $sql_where = "WHERE `song`.`catalog` IN {$catlist} ";
     }
     $sql_limit = "";
     if ($offset > 0 && $size > 0) {
         $sql_limit = "LIMIT " . $offset . ", " . $size;
     } elseif ($size > 0) {
         $sql_limit = "LIMIT " . $size;
     } elseif ($offset > 0) {
         // MySQL doesn't have notation for last row, so we have to use the largest possible BIGINT value
         // https://dev.mysql.com/doc/refman/5.0/en/select.html
         $sql_limit = "LIMIT " . $offset . ", 18446744073709551615";
     }
     $sql = "SELECT `artist`.`id`, `artist`.`name`, `artist`.`summary`, (SELECT COUNT(DISTINCT album) from `song` as `inner_song` WHERE `inner_song`.`artist` = `song`.`artist`) AS `albums`" . "FROM `song` LEFT JOIN `artist` ON `artist`.`id` = `song`.`artist` " . $sql_where . "GROUP BY `artist`.`id`, `artist`.`name`, `artist`.`summary`, `song`.`artist` ORDER BY `artist`.`name` " . $sql_limit;
     $results = array();
     $db_results = Dba::read($sql);
     while ($r = Dba::fetch_assoc($db_results)) {
         $results[] = Artist::construct_from_array($r);
     }
     return $results;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:32,代码来源:catalog.class.php


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