Skip to content

Commit 393272f

Browse files
committed
Adding travis support
1 parent 074ce98 commit 393272f

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
language: php
2+
3+
php:
4+
- 5.5
5+
6+
before_script:
7+
- wget http://getcomposer.org/composer.phar
8+
- php composer.phar install --dev --no-interaction
9+
10+
script:
11+
- mkdir -p build/logs
12+
- phpunit --coverage-clover build/logs/clover.xml
13+
14+
after_script:
15+
- php vendor/bin/coveralls -v

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,37 @@ How does it work?
1010
Easy! You write the query with all possible parameters.
1111

1212
```php
13+
use Mouf\Database\MagicQuery;
14+
1315
$sql = "SELECT * FROM users WHERE name LIKE :name AND country LIKE :country";
1416

1517
// Get a MagicQuery object.
1618
$magicQuery = new MagicQuery();
1719

1820
// Let's pass only the "name" parameter
1921
$result = $magicQuery->build($sql, [ "name" => "%John%" ]);
20-
// $result = SELECT * FROM users WHERE name LIKE '%John'
22+
// $result = SELECT * FROM users WHERE name LIKE '%John%'
2123

2224
// Let's pass no parameter at all!
2325
$result2 = $magicQuery->build($sql, []);
2426
// $result2 = SELECT * FROM users
2527
```
2628

29+
Installation
30+
------------
31+
32+
Simply use the composer package:
33+
34+
```json
35+
{
36+
"require": {
37+
"mouf/magic-query": "~1.0"
38+
},
39+
"minimum-stability": "dev",
40+
"prefer-stable": true
41+
}
42+
```
43+
2744
Why should I care?
2845
------------------
2946

@@ -68,3 +85,22 @@ version of the php-sql-parser library) and then changed into a tree.
6885
The magic happens on the tree where the node containing unused parameters
6986
are simply discarded. When it's done, the tree is changed back to SQL and
7087
"shazam!", your SQL query is purged of useless parameters!
88+
89+
Is it a MySQL only tool?
90+
------------------------
91+
92+
No. By default, your SQL is parsed and then rewritten using the MySQL dialect, but you use any kind of dialect
93+
known by Doctrine DBAL. Magic-query optionally uses Doctrine DBAL. You can pass a `Connection` object
94+
as the first parameter of the `MagicQuery` constructor. Magic-query will then use the matching dialect.
95+
96+
For instance:
97+
98+
```php
99+
$config = new \Doctrine\DBAL\Configuration();
100+
$connectionParams = array(
101+
'url' => 'sqlite:///somedb.sqlite',
102+
);
103+
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
104+
105+
$magicQuery = new \Mouf\Database\MagicQuery($conn);
106+
```

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"mouf/utils.common.sortable-interface": "~1.0"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "~4.0"
23+
"phpunit/phpunit": "~4.0",
24+
"satooshi/php-coveralls": "dev-master"
2425
},
2526
"suggest": {
2627
"doctrine/dbal": "To support more databases than just MySQL",

0 commit comments

Comments
 (0)