mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-27 11:49:56 +03:00
Feature_1255 :
- single quotes in queries - start using $conf['dblayer'] git-svn-id: http://piwigo.org/svn/trunk@4385 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
13ea9d50e3
commit
c96097529e
15 changed files with 101 additions and 24 deletions
|
@ -538,6 +538,79 @@ function boolean_to_string($var)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* interval and date functions
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
function pwg_db_get_recent_period_expression($period, $date='CURRENT_DATE')
|
||||
{
|
||||
if ($date!='CURRENT_DATE')
|
||||
{
|
||||
$date = '\''.$date.'\'';
|
||||
}
|
||||
|
||||
return 'SUBDATE('.$date.',INTERVAL '.$period.' DAY)';
|
||||
}
|
||||
|
||||
function pwg_db_get_recent_period($period, $date='CURRENT_DATE')
|
||||
{
|
||||
$query = '
|
||||
SELECT '.pwg_db_get_recent_period_expression($period);
|
||||
list($d) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
return $d;
|
||||
}
|
||||
|
||||
function pwg_db_get_date_YYYYMM($date)
|
||||
{
|
||||
return 'DATE_FORMAT('.$date.', \'%Y%m\')';
|
||||
}
|
||||
|
||||
function pwg_db_get_date_MMDD($date)
|
||||
{
|
||||
return 'DATE_FORMAT('.$date.', \'%m%d\')';
|
||||
}
|
||||
|
||||
function pwg_db_get_year($date)
|
||||
{
|
||||
return 'YEAR('.$date.')';
|
||||
}
|
||||
|
||||
function pwg_db_get_month($date)
|
||||
{
|
||||
return 'MONTH('.$date.')';
|
||||
}
|
||||
|
||||
function pwg_db_get_week($date, $mode=null)
|
||||
{
|
||||
if ($mode)
|
||||
{
|
||||
return 'WEEK('.$date.', '.$mode.')';
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'WEEK('.$date.')';
|
||||
}
|
||||
}
|
||||
|
||||
function pwg_db_get_dayofmonth($date)
|
||||
{
|
||||
return 'DAYOFMONTH('.$date.')';
|
||||
}
|
||||
|
||||
function pwg_db_get_dayofweek($date)
|
||||
{
|
||||
return 'DAYOFWEEK('.$date.')';
|
||||
}
|
||||
|
||||
function pwg_db_get_weekday($date)
|
||||
{
|
||||
return 'WEEKDAY('.$date.')';
|
||||
}
|
||||
|
||||
// my_error returns (or send to standard output) the message concerning the
|
||||
// error occured for the last mysql query.
|
||||
function my_error($header, $die)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue