Skip to content

Commit

Permalink
Merge pull request #20 from jspeedz/development
Browse files Browse the repository at this point in the history
Aliased parameters where not split by word boundary and add live template to docs
  • Loading branch information
jspeedz committed Feb 18, 2020
2 parents 3c4f681 + 2a39f47 commit c7ba948
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ if($this->container->getParameter('kernel.environment') === 'dev') {
}
```

```php
if($this->container->getParameter('kernel.environment') === 'dev') {
dumpSimpleXmlElementTree($END$);
die(__FILE__ . ':' . __LINE__);
}
```

## Install
Please only install this package for development:

Expand Down
2 changes: 1 addition & 1 deletion src/Pooper/QueryDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function dump(string $query, array $params = [], array $types = []
if(!is_numeric(array_pop($keys))) {
// These are named indexes
foreach($params as $param => $value) {
$query = str_replace(':' . $param, $value, $query);
$query = preg_replace('/:' . $param . '\b/', $value, $query);
}
}
else {
Expand Down
9 changes: 9 additions & 0 deletions src/Tests/Pooper/QueryDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ public function testQueryDumperWithAliasedParameters() {
$this->assertEquals('SELECT 1 FROM x WHERE x.y = 1 OR x.z = 2 AND x.x = "abc" AND x.a IN(1, 2, 3) AND x.b IN("a", "b", "c")', $result);
}

public function testQueryDumperWithAliasedParametersEndingOnSelf() {
$result = QueryDumper::dump('SELECT 1 FROM x WHERE x.y = :dingExtended OR x.z = :ding', [
'ding' => 'a',
'dingExtended' => 'b',
], [], true);

$this->assertEquals('SELECT 1 FROM x WHERE x.y = "b" OR x.z = "a"', $result);
}

public function testQueryDumperWithParametersAndTypes() {
$result = QueryDumper::dump('SELECT 1 FROM x WHERE x.y = ? OR x.z = ? AND x.a IN(?) AND x.b IN(?)', [
1,
Expand Down

0 comments on commit c7ba948

Please sign in to comment.