Im having a problem with a sql query. This is the original function:
function selectAllSorted($active)
{
return $this->selectObjects("SELECT bp.*, p.title as product_title
FROM $this->_table bp
INNER JOIN ?_product p USING (product_id)
ORDER BY 0+sort_order,p.title");
}
Which i modified it to look like this:
function selectAllSorted($active)
{
return $this->selectObjects("SELECT bp.*, p.title as product_title
FROM $this->_table bp
WHERE product_id =$active
INNER JOIN ?_product p USING (product_id)
ORDER BY 0+sort_order,p.title");
}
But i get an unknown error and since i cant see the logs i cant pinpoint where it is or why is it wrong to use WHERE here.
This is how the function selectObjects is defined:
function selectObjects($sql, $param1 = null)
{
$args = func_get_args();
$q = call_user_func_array(array($this->_db, 'queryResultOnly'), $args);
$ret = array();
while ($row = $this->_db->fetchRow($q))
{
$obj = new $this->_recordClass($this);
$obj->fromRow($row);
$ret[] = $obj;
}
return $ret;
}
Can you guys figure out whats wrong?
Thank you.
WHEREclause and place it after theJOIN