From a3ea7a647074f9f9ae064a73d7e40c5f020b5d5b Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Wed, 9 Apr 2014 17:12:09 +0100 Subject: [PATCH] Add BETWEEN option to WHERE --- core/lib/EddyModel.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/lib/EddyModel.php b/core/lib/EddyModel.php index 13d57d3..ae380f7 100644 --- a/core/lib/EddyModel.php +++ b/core/lib/EddyModel.php @@ -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]; @@ -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 ) {