4
link_table has to be the field name from 'the link table' that is the relation to the object table.
an example from publisher module (the other way to do it. since we wanted all the fields and wanted it to be an object we did it this way) a lot of the code was for the criteria.
$itemhandler = $publisher->getHandler('item');
$itemhandler->table_link = $xoopsDB->prefix('publisher_categories');
$itemhandler->field_link = 'categoryid';
$itemhandler->field_object = 'categoryid';
// Categories for which user has access
$categoriesGranted = $publisher->getHandler('permission')->getGrantedItems('category_read');
$grantedCategories = new Criteria('l.categoryid', "(" . implode(',', $categoriesGranted) . ")", 'IN');
$criteria = new CriteriaCompo();
$criteria->add($grantedCategories, 'AND');
$criteria->add(new Criteria('o.status',2), 'AND');
$critdatesub = new CriteriaCompo();
$critdatesub->add(new Criteria('o.datesub', $monthstart, '>'), 'AND');
$critdatesub->add(new Criteria('o.datesub', $monthend, '<='), 'AND');
$criteria->add($critdatesub);
$criteria->setSort('o.datesub');
$criteria->setOrder('DESC');
$storyarray = $itemhandler->getByLink($criteria);
changing it this way should work too.
$itemhandler = $publisher->getHandler('item');
$itemhandler->table_link = $xoopsDB->prefix('publisher_categories');
// Categories for which user has access
$categoriesGranted = $publisher->getHandler('permission')->getGrantedItems('category_read');
$grantedCategories = new Criteria('l.categoryid', "(" . implode(',', $categoriesGranted) . ")", 'IN');
$criteria = new CriteriaCompo();
$criteria->add($grantedCategories, 'AND');
$criteria->add(new Criteria('o.status',2), 'AND');
$critdatesub = new CriteriaCompo();
$critdatesub->add(new Criteria('o.datesub', $monthstart, '>'), 'AND');
$critdatesub->add(new Criteria('o.datesub', $monthend, '<='), 'AND');
$criteria->add($critdatesub);
$criteria->setSort('o.datesub');
$criteria->setOrder('DESC');
$storyarray = $itemhandler->getByLink($criteria,null,true,'categoryid','categoryid');
CBB / LatestNews / Publisher / XM-Spotlight
(ノ◕ヮ◕)ノ*:・゚✧