Example #1
0
 private function getWorks($artist, $warning)
 {
     # set group_concat_max_len explicitly so that we are always testing agains the same limit
     ApiBase::doQuery('SET SESSION group_concat_max_len = ' . ApiBase::group_concat_max_len);
     $query = '
             SELECT al.`artist` as artist, GROUP_CONCAT(al.`object` SEPARATOR "|") AS objects
             FROM `artist_links` al
             INNER JOIN `artist_table` at ON at.`id` = al.`artist`
             WHERE at.`id` in (
             "' . implode('", "', array_map('mysql_real_escape_string', $artist)) . '"
             )
             GROUP BY artist;';
     #do query
     try {
         $response = ApiBase::doQuery($query);
     } catch (Exception $e) {
         return ApiBase::makeErrorResult('610', 'Select Failed. ' . 'Probably wrong name supplied.[' . $e->getMessage() . ']', $warning);
     }
     #check that results were not truncated, since this is a silent fail
     try {
         ApiBase::groupConcatTest($response, 'objects', 'works');
     } catch (CharacterLimitException $e) {
         $w = $e->getMessage();
     }
     # put together new array of works
     $works = array();
     foreach ($response as $r) {
         $works[$r['artist']] = explode('|', $r['objects']);
     }
     return array($works, $w);
 }