| 1 | <?php |
||
| 5 | class Operators |
||
| 6 | { |
||
| 7 | const OPERATORS = array( |
||
| 8 | '>' => array( |
||
| 9 | 'format' => '> ?', |
||
| 10 | 'prepared' => true |
||
| 11 | ), |
||
| 12 | '>=' => array( |
||
| 13 | 'format' => '>= ?', |
||
| 14 | 'prepared' => true |
||
| 15 | ), |
||
| 16 | '<' => array( |
||
| 17 | 'format' => '< ?', |
||
| 18 | 'prepared' => true |
||
| 19 | ), |
||
| 20 | '<=' => array( |
||
| 21 | 'format' => '<= ?', |
||
| 22 | 'prepared' => true |
||
| 23 | ), |
||
| 24 | '!=' => array( |
||
| 25 | 'format' => '!= ?', |
||
| 26 | 'prepared' => true |
||
| 27 | ), |
||
| 28 | 'LIKE' => array( |
||
| 29 | 'format' => 'LIKE ?', |
||
| 30 | 'prepared' => true |
||
| 31 | ), |
||
| 32 | 'NOT LIKE' => array( |
||
| 33 | 'format' => 'NOT LIKE ?', |
||
| 34 | 'prepared' => true |
||
| 35 | ), |
||
| 36 | 'IN' => array( |
||
| 37 | 'format' => 'IN (%s)', |
||
| 38 | 'prepared' => true |
||
| 39 | ), |
||
| 40 | 'NOT IN' => array( |
||
| 41 | 'format' => 'NOT IN (%s)', |
||
| 42 | 'prepared' => true |
||
| 43 | ), |
||
| 44 | 'BETWEEN' => array( |
||
| 45 | 'format' => 'BETWEEN ? AND ?', |
||
| 46 | 'prepared' => true |
||
| 47 | ), |
||
| 48 | 'NOT BETWEEN' => array( |
||
| 49 | 'format' => 'NOT BETWEEN ? AND ?', |
||
| 50 | 'prepared' => true |
||
| 51 | ), |
||
| 52 | 'IS NULL' => array( |
||
| 53 | 'format' => 'IS NULL', |
||
| 54 | 'prepared' => false |
||
| 55 | ), |
||
| 56 | 'IS NOT NULL' => array( |
||
| 57 | 'format' => 'IS NOT NULL', |
||
| 58 | 'prepared' => false |
||
| 59 | ) |
||
| 60 | ); |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Gets the correct formated string for the operator |
||
| 64 | * @param string $value This should be the operator value |
||
| 65 | * @return string The string to add to the database will be added |
||
| 66 | 2 | */ |
|
| 67 | 2 | public static function getOperatorFormat($value) |
|
| 74 | |||
| 75 | /** |
||
| 76 | 7 | * Checks to see if the operator is valid |
|
| 77 | 7 | * @param string $operator This should be the operator value |
|
| 78 | 6 | * @return boolean If the operator exists in the array will return true else returns false |
|
| 79 | */ |
||
| 80 | public static function isOperatorValid($operator) |
||
| 87 | 1 | ||
| 88 | /** |
||
| 89 | * Checks to see if a prepared statement value should be added |
||
| 90 | * @param string $value This should be the operator value |
||
| 91 | * @return boolean If the operator should be prepared returns true else returns false |
||
| 92 | */ |
||
| 93 | public static function isOperatorPrepared($value) |
||
| 97 | } |
||
| 98 |