Skip to content
Permalink
Browse files
Bug 1754 fixed : The keyword AS is mandatory for alias in PostgreSQL …
…queries

git-svn-id: http://piwigo.org/svn/trunk@6652 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
nikrou committed Jul 3, 2010
1 parent 58cb482 commit dd955526ae97b8f830db2f499ab5c57efe874e5b
Showing 4 changed files with 10 additions and 10 deletions.
@@ -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 @@ function get_recent_post_dates($max_dates, $max_elements, $max_cats)
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.'
@@ -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).')';
@@ -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
@@ -285,7 +285,7 @@ function ws_categories_getImages($params, &$service)
$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 @@ function ws_images_getInfo($params, &$service)
}

$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';

0 comments on commit dd95552

Please sign in to comment.