Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
Add BETWEEN option to WHERE
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Hamp committed Apr 9, 2014
1 parent 6990519 commit a3ea7a6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/lib/EddyModel.php
Expand Up @@ -340,6 +340,12 @@ protected static function find( $table = null, $args = array() ) {
$value = preg_replace( '/^' . $comparison . '/', '', $value );
}

if ( preg_match( '/^BETWEEN (.+) AND (.+)/', $value ) ) {
$comparison = '';
$value = $value;
$between = true;
}

if ( preg_match( '/^(!|NOT\s)?IN\((.+)\)/', $value, $set ) ) {
$comparison = $set[1] ? 'NOT ' : '';
$value = $set[2];
Expand All @@ -356,7 +362,7 @@ protected static function find( $table = null, $args = array() ) {
$comparison = 'IS';
}
}
elseif ( is_string( $value ) && !$in_set ) {
elseif ( is_string( $value ) && !$in_set && !$between ) {
$value = '"' . EddyDB::esc_str( $value ) . '"';
}
elseif ( $in_set ) {
Expand Down

0 comments on commit a3ea7a6

Please sign in to comment.