好的,我知道這應該很簡單,但我會圍繞着圈子。我有兩個表和兩個函數,每個運行查詢,第一個函數獲取產品,第二個獲取產品圖像從兩個表格構建一個數組(從一個表格中獲取一個表格以獲得另一個表格的產品)
我想獲得一個數組,它是產品,它的圖像...
這裏是我的代碼...
/**
* 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);
}