如何在Jreviews页面中“回显”基本SQL查询?我正在使用Joomla 2.5。
查询:
SELECT COUNT(product) AS totalcount FROM my_table WHERE productid LIKE = 'sony'
Jreviews基于PHP(如Joomla)。
预期结果,例如:
Sony product: 105
答案 0 :(得分:2)
查询错误
SELECT COUNT(product) AS totalcount
FROM my_table
WHERE productid LIKE '%sony%'
或
SELECT COUNT(product) AS totalcount
FROM my_table
WHERE productid = 'sony'
但不是LIKE =
答案 1 :(得分:0)
根据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>";