vendredi 8 juillet 2016

No results returned by MySQL query

I am testing an application which connects to database and retrieve results. It uses PHP, and Joomla framework. The thing is that if I put a query as

$query = "SELECT * FROM #__coupon_member_details";
$this->_db->setQuery($query);        
$result = $this->_db->query();
$number = mysql_num_rows($result);
if($number == 0 ){
        JFactory::getApplication()->enqueueMessage("no data returned by db");
}else{
        JFactory::getApplication()->enqueueMessage($number);
}

The above code gives message "no data returned by db" except the fact that the table contains a lot of data (200+ rows).

If I put invalid table name as #__coupon_member_details123, then it produces an error saying "Table does not exist".

I fail to understand what is wrong ?

Aucun commentaire:

Enregistrer un commentaire