euautomation / canon
A WHERE matching thing
Installs: 16 878
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.3.0
- ext-mbstring: *
Requires (Dev)
- mockery/mockery: ^1.4
- phpunit/phpunit: ^9
README
Using something like the WHERE part of an SQL query to evaluate an array like thing is true or false.
Basic Usage
use EUAutomation\Canon\Processor; $processor = new Processor(); $expressions = $processor->process('foo = "bar"'); $expressions->evaluate([ "foo" => "bar" ]); // true
Supports
- Basic Operators (=, !=, >, >=, <, <=)
foo > 9000
- LIKE Operator
foo LIKE "shoes%"
- LIKE ANY Operator
foo LIKE ANY ("shoes%", "socks%")
- IN Operator
foo IN (1, 2)
- Nested Columns Refs
foo.bar = 'baz'
- Brackets
foo = 2 AND (bar = 3 OR baz < 10)
Acknowledgments
- https://github.com/greenlion/PHP-SQL-Parser - lots of the parser code is from here