getContentList

by sylvie
Thursday, August 31, 2006
Posted to sylvie's Blog
getContentList is already calling the service content_list_sql_function and do a loop for each object to have complementary information

To have getContentList to be able to filter not only on information in the content table but also on infomation on the foreign object and to be able to give back information not only from the content table but from the foriegn object

Proposal
Call example:

<?php
$hash
['max_records'] = -1;
$hash['offset'] = 0;
$hash['pigeonholes'] = array(316,334); // use the service pigeonhole - an array of categories = OR between categories
$hash['last_modified'] = '1156533432'// use filter on liberty_content - modified since
$hash['content_type_guid'] = array( 'musicartist''bituser');// use filter on liberty_content

$res $gBitUser->getContentList($hash);
echo 
"<pre>";print_r($res);
?>


For each content_type_guid, a function will be called if exists. All the currnet hash are passed to this function so that the filter can use input parameter. the output can be an array $pSqlselect>'select', an array $pSqljoin>'join', an array $pSqlwhere>'where',$pBindVarsselect>'select', an array $pBindVarsjoin>'join', an array $pBindVarswhere>'where',

<?php
    
function getFilterSql(&$pSql, &$pBindVars$pHash null) {
        
$pSql['select'][] = $this->mDb->Concat('?',"music_artist.`artist_id`" )." AS musicartist_url";
        
$pSql['join'][] = "LEFT JOIN `".BIT_DB_PREFIX."music_artist` music_artist ON( music_artist.`content_id` = lc.`content_id` )";
        
$pBindVars[] = "'".MUSIC_PKG_URL."artist.php?artist_id='";
    }
?>


The limitation:
- each returned select field must be name differently . Ex: you can not use display_url but musicartist_url

Objective:
As soon as such function will be created, we will delete in the actual getContentList the horrible slow loop that for each object go to fetch display_url, display_link and title - 2or 3 queries per object.
THe code wil looks like

<?php
if (!empty($aux[$type.'url'])) {
    
$aux['display_url'] = $aux[$type.'url']
}else {
    
$aux['display_url']  = $type['content_object']->getDisplayUrl$aux['content_id'], $aux );
}
?>