Changeset 4385 for trunk/include/dblayer


Ignore:
Timestamp:
Nov 29, 2009, 1:35:19 PM (15 years ago)
Author:
nikrou
Message:

Feature_1255 :

  • single quotes in queries
  • start using $confdblayer
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/dblayer/functions_mysql.inc.php

    r4367 r4385  
    539539}
    540540
     541/**
     542 *
     543 * interval and date functions
     544 *
     545 */
     546
     547
     548function pwg_db_get_recent_period_expression($period, $date='CURRENT_DATE')
     549{
     550  if ($date!='CURRENT_DATE')
     551  {
     552    $date = '\''.$date.'\'';
     553  }
     554
     555  return 'SUBDATE('.$date.',INTERVAL '.$period.' DAY)';
     556}
     557
     558function pwg_db_get_recent_period($period, $date='CURRENT_DATE')
     559{
     560  $query = '
     561SELECT '.pwg_db_get_recent_period_expression($period);
     562  list($d) = pwg_db_fetch_row(pwg_query($query));
     563
     564  return $d;
     565}
     566
     567function pwg_db_get_date_YYYYMM($date)
     568{
     569  return 'DATE_FORMAT('.$date.', \'%Y%m\')';
     570}
     571
     572function pwg_db_get_date_MMDD($date)
     573{
     574  return 'DATE_FORMAT('.$date.', \'%m%d\')';
     575}
     576
     577function pwg_db_get_year($date)
     578{
     579  return 'YEAR('.$date.')';
     580}
     581
     582function pwg_db_get_month($date)
     583{
     584  return 'MONTH('.$date.')';
     585}
     586
     587function pwg_db_get_week($date, $mode=null)
     588{
     589  if ($mode)
     590  {
     591    return 'WEEK('.$date.', '.$mode.')';
     592  }
     593  else
     594  {
     595    return 'WEEK('.$date.')';
     596  }
     597}
     598
     599function pwg_db_get_dayofmonth($date)
     600{
     601  return 'DAYOFMONTH('.$date.')';
     602}
     603
     604function pwg_db_get_dayofweek($date)
     605{
     606  return 'DAYOFWEEK('.$date.')';
     607}
     608
     609function pwg_db_get_weekday($date)
     610{
     611  return 'WEEKDAY('.$date.')';
     612}
     613
    541614// my_error returns (or send to standard output) the message concerning the
    542615// error occured for the last mysql query.
Note: See TracChangeset for help on using the changeset viewer.