Bug 1754 fixed : The keyword AS is mandatory for alias in PostgreSQL queries

Merge from trunk

git-svn-id: http://piwigo.org/svn/branches/2.1@6653 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
nikrou 2010-07-03 12:16:12 +00:00
parent 55f4efd7a6
commit b83df6be68
4 changed files with 10 additions and 10 deletions

View file

@ -476,8 +476,8 @@ function get_recent_post_dates($max_dates, $max_elements, $max_cats)
$query = '
SELECT date_available,
COUNT(DISTINCT id) nb_elements,
COUNT(DISTINCT category_id) nb_cats
COUNT(DISTINCT id) AS nb_elements,
COUNT(DISTINCT category_id) AS nb_cats
FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id
'.$where_sql.'
GROUP BY date_available
@ -515,7 +515,7 @@ SELECT id, path, name, tn_ext, file
if ($max_cats>0)
{// get some categories ...
$query = '
SELECT c.uppercats, COUNT(DISTINCT i.id) img_count
SELECT c.uppercats, COUNT(DISTINCT i.id) AS img_count
FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id=image_id
INNER JOIN '.CATEGORIES_TABLE.' c ON c.id=category_id
'.$where_sql.'

View file

@ -36,7 +36,7 @@ function get_available_tags()
{
// we can find top fatter tags among reachable images
$query = '
SELECT tag_id, COUNT(DISTINCT(it.image_id)) counter
SELECT tag_id, COUNT(DISTINCT(it.image_id)) AS counter
FROM '.IMAGE_CATEGORY_TABLE.' ic
INNER JOIN '.IMAGE_TAG_TABLE.' it ON ic.image_id=it.image_id'.get_sql_condition_FandF
(
@ -223,7 +223,7 @@ function get_common_tags($items, $max_tags, $excluded_tag_ids=null)
return array();
}
$query = '
SELECT t.*, count(*) counter
SELECT t.*, count(*) AS counter
FROM '.IMAGE_TAG_TABLE.'
INNER JOIN '.TAGS_TABLE.' t ON tag_id = id
WHERE image_id IN ('.implode(',', $items).')';

View file

@ -678,10 +678,10 @@ function compute_categories_data(&$cats)
*/
function get_computed_categories($userdata, $filter_days=null)
{
$query = 'SELECT c.id cat_id, global_rank';
$query = 'SELECT c.id AS cat_id, global_rank';
// Count by date_available to avoid count null
$query .= ',
MAX(date_available) date_last, COUNT(date_available) nb_images
MAX(date_available) AS date_last, COUNT(date_available) AS nb_images
FROM '.CATEGORIES_TABLE.' as c
LEFT JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON ic.category_id = c.id
LEFT JOIN '.IMAGES_TABLE.' AS i

View file

@ -285,7 +285,7 @@ SELECT id, name, permalink, image_order
$order_by = empty($order_by) ? $conf['order_by'] : 'ORDER BY '.$order_by;
$query = '
SELECT i.*, GROUP_CONCAT(category_id) cat_ids
SELECT i.*, GROUP_CONCAT(category_id) AS cat_ids
FROM '.IMAGES_TABLE.' i
INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON i.id=image_id
WHERE '. implode('
@ -693,7 +693,7 @@ SELECT COUNT(rate) AS count
}
$query = '
SELECT COUNT(id) nb_comments
SELECT COUNT(id) AS nb_comments
FROM '.COMMENTS_TABLE.'
WHERE '.$where_comments;
list($nb_comments) = array_from_query($query, 'nb_comments');
@ -1454,7 +1454,7 @@ function ws_tags_getImages($params, &$service)
else
{
$query = '
SELECT image_id, GROUP_CONCAT(tag_id) tag_ids
SELECT image_id, GROUP_CONCAT(tag_id) AS tag_ids
FROM '.IMAGE_TAG_TABLE.'
WHERE tag_id IN ('.implode(',',$tag_ids).')
GROUP BY image_id';