1+ [ ![ Latest Unstable Version] ( https://poser.pugx.org/mouf/magic-query/v/unstable )] ( https://packagist.org/packages/mouf/magic-query )
2+ [ ![ License] ( https://poser.pugx.org/mouf/magic-query/license )] ( https://packagist.org/packages/mouf/magic-query )
13[ ![ Scrutinizer Code Quality] ( https://scrutinizer-ci.com/g/thecodingmachine/magic-query/badges/quality-score.png?b=1.0 )] ( https://scrutinizer-ci.com/g/thecodingmachine/magic-query/?branch=1.0 )
24[ ![ Build Status] ( https://travis-ci.org/thecodingmachine/magic-query.svg?branch=1.0 )] ( https://travis-ci.org/thecodingmachine/magic-query )
35[ ![ Coverage Status] ( https://coveralls.io/repos/thecodingmachine/magic-query/badge.svg?branch=1.0 )] ( https://coveralls.io/r/thecodingmachine/magic-query?branch=1.0 )
@@ -24,10 +26,12 @@ $magicQuery = new MagicQuery();
2426// Let's pass only the "name" parameter
2527$result = $magicQuery->build($sql, [ "name" => "%John%" ]);
2628// $result = SELECT * FROM users WHERE name LIKE '%John%'
29+ // Did you notice how the bit about the country simply vanished?
2730
2831// Let's pass no parameter at all!
2932$result2 = $magicQuery->build($sql, []);
3033// $result2 = SELECT * FROM users
34+ // The whole WHERE condition disappeared because it is not needed anymore!
3135```
3236
3337Installation
@@ -71,7 +75,7 @@ if (isset($params['country'])) {
7175```
7276
7377Concatenating SQL queries is ** dangerous** (especially if you forget to protect parameters).
74- You can always use parameterized SQL queries, but you will still have to concatenate the filters.
78+ You can always use parametrized SQL queries, but you will still have to concatenate the filters.
7579
7680To avoid concatenating strings, frameworks and libraries have used different strategies. Building a full ORM (like
7781Doctrine or Propel) is a good idea, but it makes writing complex queries even more complex. Other frameworks like
0 commit comments