Skip to content

Commit

Permalink
Bug 1730 fixed : search doesn't work when database engine is not mysql
Browse files Browse the repository at this point in the history
For posgresql and sqlite date must allways use day and month with two diggits.

git-svn-id: http://piwigo.org/svn/trunk@6518 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
nikrou committed Jun 10, 2010
1 parent 09e7d9c commit ce18786
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion include/functions_search.inc.php
Expand Up @@ -223,7 +223,7 @@ function get_regular_search_results($search, $images_where)
if (!empty($search_clause))
{
$query = '
SELECT DISTINCT(id)
SELECT id
FROM '.IMAGES_TABLE.' i
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE '.$search_clause;
Expand Down
28 changes: 12 additions & 16 deletions search.php
Expand Up @@ -39,7 +39,7 @@
{
if (!is_array($post_value))
{
$_POST[$post_key] = mysql_real_escape_string($post_value);
$_POST[$post_key] = pwg_db_real_escape_string($post_value);
}
}

Expand Down Expand Up @@ -106,13 +106,11 @@
if (!empty($_POST['start_year']))
{
$search['fields'][$type_date.'-after'] = array(
'date' => join(
'-',
array(
$_POST['start_year'],
$_POST['start_month'] != 0 ? $_POST['start_month'] : '01',
$_POST['start_day'] != 0 ? $_POST['start_day'] : '01',
)
'date' => sprintf(
'%d-%02d-%02d',
$_POST['start_year'],
$_POST['start_month'] != 0 ? $_POST['start_month'] : '01',
$_POST['start_day'] != 0 ? $_POST['start_day'] : '01'
),
'inc' => true,
);
Expand All @@ -121,14 +119,12 @@
if (!empty($_POST['end_year']))
{
$search['fields'][$type_date.'-before'] = array(
'date' => join(
'-',
array(
$_POST['end_year'],
$_POST['end_month'] != 0 ? $_POST['end_month'] : '12',
$_POST['end_day'] != 0 ? $_POST['end_day'] : '31',
)
),
'date' => sprintf(
'%d-%02d-%02d',
$_POST['end_year'],
$_POST['end_month'] != 0 ? $_POST['end_month'] : '12',
$_POST['end_day'] != 0 ? $_POST['end_day'] : '31'
),
'inc' => true,
);
}
Expand Down

0 comments on commit ce18786

Please sign in to comment.