如何在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