好的,我知道这应该很简单,但我会围绕着圈子。我有两个表和两个函数,每个运行查询,第一个函数获取产品,第二个获取产品图像从两个表格构建一个数组(从一个表格中获取一个表格以获得另一个表格的产品)
我想获得一个数组,它是产品,它的图像...
这里是我的代码...
/**
* Gets the requested product from the DB
*
* @param string $productUrl
* @param string $productID
*/
private function _db_get_product($productUrl = null, $productID = null) {
if (empty($productUrl) && empty($productID))
return;
$db = $this->getConnection();
$q = "SELECT " . $this->_leaf_sql_fields() .
" FROM content_products_items pr WHERE pr.productStatus >= "
. menuMachine::getMinimumStatus() . " ";
if (!empty($productUrl))
$q .= " AND productUrl = '" . $productUrl . "'";
if (!empty($productID))
$q .= " AND productID = '" . $productID . "'";
if ($res = $db->recordsetSingle($q))
$this->_product = $res;
return $res;
}
/**
* Get the images for the product
* @return array
*/
private function _db_get_product_images($productID) {
$db = $this->getConnection();
$q = "SELECT * FROM content_products_images WHERE productID = '" . $productID . "'";
$this->_productImages = $db->recordset($q);
}