I am trying to have the module check a table in the database and return the higest amount in the column. (using sourcerer plugin to use php in a wysiwyg module). However I just get..nothing. No error, but no returned info either.
我试图让模块检查数据库中的表并返回列中的最大量。 (使用sourcerer插件在wysiwyg模块中使用php)。但是我得到......没什么。没有错误,但也没有返回信息。
<?php
$db = new mysqli('localhost', 'user', 'pass', 'db');
$query = 'SELECT MAX(Amount) AS Amount FROM nud9b_auction';
$result = $db->query($query);
$row = $result->fetch_row();
echo $row['Amount'];
$result->close();
?>
1 个解决方案
#1
2
$db = JFactory::getDbo();
$db->setQuery('SELECT MAX(Amount) AS Amount FROM #__auction');
echo $db->loadResult();
You need not write joomla table prefix in qquery.
您不需要在qquery中编写joomla表前缀。
Full guide here: https://docs.joomla.org/Selecting_data_using_JDatabase
完整指南:https://docs.joomla.org/Selecting_data_using_JDatabase
#1
2
$db = JFactory::getDbo();
$db->setQuery('SELECT MAX(Amount) AS Amount FROM #__auction');
echo $db->loadResult();
You need not write joomla table prefix in qquery.
您不需要在qquery中编写joomla表前缀。
Full guide here: https://docs.joomla.org/Selecting_data_using_JDatabase
完整指南:https://docs.joomla.org/Selecting_data_using_JDatabase