如何在Jreviews页面中“回显”基本的SQL查询?我使用的是Joomla 2.5。在jreviews页面中的SQL查询,joomla 2.5
查询:
SELECT COUNT(product) AS totalcount FROM my_table WHERE productid LIKE = 'sony'
Jreviews是基于PHP(如Joomla)。
预期结果,例如:
Sony product: 105
如何在Jreviews页面中“回显”基本的SQL查询?我使用的是Joomla 2.5。在jreviews页面中的SQL查询,joomla 2.5
查询:
SELECT COUNT(product) AS totalcount FROM my_table WHERE productid LIKE = 'sony'
Jreviews是基于PHP(如Joomla)。
预期结果,例如:
Sony product: 105
查询是错误的
SELECT COUNT(product) AS totalcount
FROM my_table
WHERE productid LIKE '%sony%'
或
SELECT COUNT(product) AS totalcount
FROM my_table
WHERE productid = 'sony'
但不LIKE =
根据的Joomla的基本版本你应该能够使用这样的事情 -
$db =& JFactory::getDBO();
$query = "SELECT COUNT(*)
FROM my_table
WHERE productid = 'sony'";
$db->setQuery($query);
$count = $db->loadResult();
echo "<p>Sony product: $count</p>";
是啊,对不起!只是一个mystake。 – DavidF 2012-04-13 11:34:09