aboutsummaryrefslogtreecommitdiffstats
path: root/include/dblayer/functions_mysql.inc.php
diff options
context:
space:
mode:
authornikrou <nikrou@piwigo.org>2009-11-29 12:35:19 +0000
committernikrou <nikrou@piwigo.org>2009-11-29 12:35:19 +0000
commitc96097529e49943eddba78d70e23e38c0eac494d (patch)
tree5925d92bcad222348680a3ea6253d5743dbe38a4 /include/dblayer/functions_mysql.inc.php
parent13ea9d50e35d9dd8cf7235a39d97a344e6091ea0 (diff)
Feature_1255 :
- single quotes in queries - start using $conf['dblayer'] git-svn-id: http://piwigo.org/svn/trunk@4385 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/dblayer/functions_mysql.inc.php')
-rw-r--r--include/dblayer/functions_mysql.inc.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/include/dblayer/functions_mysql.inc.php b/include/dblayer/functions_mysql.inc.php
index f21ace0f3..e47119535 100644
--- a/include/dblayer/functions_mysql.inc.php
+++ b/include/dblayer/functions_mysql.inc.php
@@ -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)