Advertisement
Viper007Bond

Untitled

Sep 20th, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. $units = array( 'hour', 'minute', 'second' );
  2. foreach ( $units as $key = $unit ) {
  3.     $other_units = $units;
  4.     unset( $other_units[$key] );
  5.     $other_units = array_values( $other_units );
  6.  
  7.     if ( isset ( $$unit ) && ! isset( $other_units[0] ) && ! isset( $other_units[1] ) )
  8.         return $wpdb->prepare( strtoupper( $unit ) . "( $column ) $compare %d", $$unit );
  9. }
  10.  
  11.  
  12.  
  13. if ( isset( $hour ) && ! isset( $minute ) && ! isset( $second ) {
  14.     return $wpdb->prepare( "HOUR( $column ) $compare %d", $hour );
  15. } elseif ( ! isset( $hour ) && isset( $minute ) && ! isset( $second ) {
  16.     return $wpdb->prepare( "MINUTE( $column ) $compare %d", $minute );
  17. } elseif ( ! isset( $hour ) && ! isset( $minute ) && isset( $second ) {
  18.     return $wpdb->prepare( "SECOND( $column ) $compare %d", $second );
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement