waps2
01-08-2012, 06:46 PM
Hi guys,
I have this function below which works until I there are more than 1 result pulled from the second inside query.
I need to modify it so it loops through the results passed from the middle query, outputting an array of results each time.
Bit stuck on this bit though so need some help ? :confused:
public function getDownloads($product_id) {
$sql = "SELECT * FROM " . DB_PREFIX . "download d LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id)" . "WHERE d.download_id = (SELECT download_id FROM " . DB_PREFIX . "product_to_download WHERE product_id = '$product_id')";
$query = $this->db->query($sql);
return $query->rows;
}
I have this function below which works until I there are more than 1 result pulled from the second inside query.
I need to modify it so it loops through the results passed from the middle query, outputting an array of results each time.
Bit stuck on this bit though so need some help ? :confused:
public function getDownloads($product_id) {
$sql = "SELECT * FROM " . DB_PREFIX . "download d LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id)" . "WHERE d.download_id = (SELECT download_id FROM " . DB_PREFIX . "product_to_download WHERE product_id = '$product_id')";
$query = $this->db->query($sql);
return $query->rows;
}