1

我想在我的 joomla 站点中触发一个复杂的查询。我已经为它写了下面的代码。

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('`chr`.`characteristic_id`,`chr`.`characteristic_value`,`prc`.`price_value`');
$query->from('`#___hikashop_product` AS `pdt`');
$query->join('inner', '`#__hikashop_variant` AS `vari` ON `pdt`.`product_id` = `vari`.`variant_characteristic_id`');
$query->join('inner', '`#__hikashop_characteristic` AS `chr` ON `vari`.`variant_characteristic_id` = `chr`.`characteristic_id`');
$query->join('inner', '`#__hikashop_price` AS `prc` ON `pdt`.`product_id` = `prc`.`price_product_id`');
$query->where('`pdt`.`product_id` = 68');
$db->setQuery($query);

查询正在我的本地 mysql 中执行。任何帮助将不胜感激

4

2 回答 2

5

你可以试试这个

$db->setQuery("Your query");
$result = $db->query();

//if you need the count
$rowcount = $db->getNumRows();

//if the result is multiple rows
$result_array = $db->loadAssocList() or $db->loadObjectList();

//if the result is single row you can use
$result = $db->loadAssoc() or $db->loadObject();
于 2012-04-27T12:35:50.730 回答
3

要触发查询,您需要做的就是:

$rows = $db->loadAssocList(); // or loadObjectList()

以上将把所有的行放入$rows

您还可以在不获取行的情况下触发查询:

$db->query();
于 2012-04-27T12:26:35.703 回答