Changeset 4385 for trunk/include/dblayer
- Timestamp:
- Nov 29, 2009, 1:35:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/dblayer/functions_mysql.inc.php
r4367 r4385 539 539 } 540 540 541 /** 542 * 543 * interval and date functions 544 * 545 */ 546 547 548 function 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 558 function pwg_db_get_recent_period($period, $date='CURRENT_DATE') 559 { 560 $query = ' 561 SELECT '.pwg_db_get_recent_period_expression($period); 562 list($d) = pwg_db_fetch_row(pwg_query($query)); 563 564 return $d; 565 } 566 567 function pwg_db_get_date_YYYYMM($date) 568 { 569 return 'DATE_FORMAT('.$date.', \'%Y%m\')'; 570 } 571 572 function pwg_db_get_date_MMDD($date) 573 { 574 return 'DATE_FORMAT('.$date.', \'%m%d\')'; 575 } 576 577 function pwg_db_get_year($date) 578 { 579 return 'YEAR('.$date.')'; 580 } 581 582 function pwg_db_get_month($date) 583 { 584 return 'MONTH('.$date.')'; 585 } 586 587 function 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 599 function pwg_db_get_dayofmonth($date) 600 { 601 return 'DAYOFMONTH('.$date.')'; 602 } 603 604 function pwg_db_get_dayofweek($date) 605 { 606 return 'DAYOFWEEK('.$date.')'; 607 } 608 609 function pwg_db_get_weekday($date) 610 { 611 return 'WEEKDAY('.$date.')'; 612 } 613 541 614 // my_error returns (or send to standard output) the message concerning the 542 615 // error occured for the last mysql query.
Note: See TracChangeset
for help on using the changeset viewer.