MySQL Select
i want to change the headings of table-columns retrieved from the database using SELECT " AS ...
This is my code...
protected function getCategoryDescriptions( &$languages, $offset=null, $rows=null, $min_id=null, $max_id=null ) {
// query the category_description table for each language
$category_descriptions = array();
foreach ($languages as $language) {
$language_id = $language['language_id'];
$language_code = $language['code'];
$sql = "SELECT c.category_id, cd.* ";
$sql .= "FROM `".DB_PREFIX."category` c ";
$sql .= "LEFT JOIN `".DB_PREFIX."category_description` cd ON cd.category_id=c.category_id AND cd.language_id='".(int)$language_id."' ";
if (isset($min_id) && isset($max_id)) {
$sql .= "WHERE c.category_id BETWEEN $min_id AND $max_id ";
}
$sql .= "GROUP BY c.`category_id` ";
$sql .= "ORDER BY c.`category_id` ASC ";
if (isset($offset) && isset($rows)) {
$sql .= "LIMIT $offset,$rows; ";
} else {
$sql .= "; ";
}
$query = $this->db->query( $sql );
$category_descriptions[$language_code] = $query->rows;
}
return $category_descriptions;
}
I have tried but all in vain. Kindly help
Subject
Written By
Posted
MySQL Select
September 23, 2016 12:51AM
September 23, 2016 08:59AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.