Feature 1255: modification in sql queries

- manage random function
    - manage regex syntax
    - manage quote (single instead of double)
    - manage interval

git-svn-id: http://piwigo.org/svn/trunk@4367 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
nikrou 2009-11-25 19:02:57 +00:00
parent d30639ec98
commit 13ea9d50e3
20 changed files with 134 additions and 112 deletions

View file

@ -121,15 +121,15 @@ function ws_std_image_sql_order( $params, $tbl_name='' )
case 'date_posted':
$matches[1][$i] = 'date_available'; break;
case 'rand': case 'random':
$matches[1][$i] = 'RAND()'; break;
$matches[1][$i] = DB_RANDOM_FUNCTION.'()'; break;
}
$sortable_fields = array('id', 'file', 'name', 'hit', 'average_rate',
'date_creation', 'date_available', 'RAND()' );
'date_creation', 'date_available', DB_RANDOM_FUNCTION.'()' );
if ( in_array($matches[1][$i], $sortable_fields) )
{
if (!empty($ret))
$ret .= ', ';
if ($matches[1][$i] != 'RAND()' )
if ($matches[1][$i] != DB_RANDOM_FUNCTION.'()' )
{
$ret .= $tbl_name;
}
@ -230,7 +230,7 @@ function ws_categories_getImages($params, &$service)
continue;
if ($params['recursive'])
{
$where_clauses[] = 'uppercats REGEXP \'(^|,)'.$cat_id.'(,|$)\'';
$where_clauses[] = 'uppercats '.DB_REGEX_OPERATOR.' \'(^|,)'.$cat_id.'(,|$)\'';
}
else
{
@ -377,7 +377,7 @@ function ws_categories_getList($params, &$service)
}
else if ($params['cat_id']>0)
{
$where[] = 'uppercats REGEXP \'(^|,)'.
$where[] = 'uppercats '.DB_REGEX_OPERATOR.' \'(^|,)'.
(int)($params['cat_id'])
.'(,|$)\'';
}