I have function and my function works good only I do not understand this:
<?php
// $category output is 23 when I echo $category; and there is no records
->where('d.category_id = ' . (int) $category)
// also this method not work
->where('d.category_id = ' . $category)
// but this method works
->where('d.category_id = 23')
?>
this is full code:
$category = $params->get('title');
//echo $category;
public static function getSuggested($category) {
$db = JFactory::getDBO();
$query = $db->getQuery(true);
//$now = $jdate->toSql();
//$nullDate = $db->quote($db->getNullDate());
$query->select('d.*');
$query->from('#__deals_deals AS d');
$query->select('c.title AS category_title');
$query->join('LEFT', '#__deals_categories AS c ON c.id = d.category_id')
->where('(d.is_market = 0 AND d.state = 1)','AND')
->where('d.category_id = 23')
->order('id DESC');
//$query->where('(d.publish_up = ' . $nullDate . ' OR d.publish_up <= ' . $query->quote($now) . ')');
//$query->where('(d.publish_down = ' . $nullDate . ' OR d.publish_down >= ' . $query->quote($now) . ')');
$db->setQuery($query,0,10);
$results = $db->loadObjectList();
return $results;
}
this function works good only need to get category data. this is joomla module, and this function is in helper.php file in default.php file I am get some data from this function.
I found solution:
Add in mod_suggested_deals.php
$category = (int) $params->get('fieldvalue');
then:
$results = modsuggested_dealsHelper::getSuggested($category);