You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An elegant lightweight and efficient SQL Query Builder with fluid interface SQL syntax supporting bindings and complicated query generation.
7
7
<aname="index_block"></a>
@@ -42,9 +42,10 @@ An elegant lightweight and efficient SQL Query Builder with fluid interface SQL
42
42
*[4.5. Columns as SELECT statements](#block4.5)
43
43
*[4.6. Columns being Values](#block4.6)
44
44
*[4.7. Columns using FUNCTIONS](#block4.7)
45
-
*[5. Quality Code](#block5)
46
-
*[6. Author](#block6)
47
-
*[7. License](#block7)
45
+
*[5. Commenting queries](#block5)
46
+
*[6. Quality Code](#block6)
47
+
*[7. Author](#block7)
48
+
*[8. License](#block8)
48
49
49
50
50
51
<aname="block1"></a>
@@ -120,8 +121,7 @@ use NilPortugues\Sql\QueryBuilder\Builder\GenericBuilder;
120
121
121
122
$builder = new GenericBuilder();
122
123
123
-
$query = $builder->select()->setTable('user');
124
-
$builder = new GenericBuilder();
124
+
$query = $builder->select()->setTable('user');
125
125
126
126
echo $builder->writeFormatted($query);
127
127
@@ -1068,10 +1068,37 @@ WHERE
1068
1068
(user.user_id= :v1)
1069
1069
```
1070
1070
1071
+
<aname="block5"></a>
1072
+
## 5. Commenting queries [↑](#index_block)
1073
+
The query builder allows adding comments to all query methods by using the `setComment` method.
1074
+
1075
+
Some useful use cases examples can be :
1071
1076
1077
+
- Explain difficult queries or why of its existence.
1078
+
- Finding slow queries from its comments.
1072
1079
1073
-
<aname="block5"></a>
1074
-
## 5. Quality Code [↑](#index_block)
1080
+
#### Usage:
1081
+
```php
1082
+
<?php
1083
+
use NilPortugues\Sql\QueryBuilder\Builder\GenericBuilder;
1084
+
1085
+
$builder = new GenericBuilder();
1086
+
1087
+
$query = $builder->select()
1088
+
->setTable('user')
1089
+
->setComment('This is a comment');
1090
+
1091
+
$sql = $builder->write($query);
1092
+
```
1093
+
1094
+
#### Output:
1095
+
```sql
1096
+
-- This is a comment
1097
+
SELECT user.*FROM user
1098
+
```
1099
+
1100
+
<aname="block6"></a>
1101
+
## 6. Quality Code [↑](#index_block)
1075
1102
Testing has been done using PHPUnit and [Travis-CI](https://travis-ci.org). All code has been tested to be compatible from PHP 5.4 up to PHP 5.6 and [HHVM](http://hhvm.com/).
1076
1103
1077
1104
To run the test suite, you need [Composer](http://getcomposer.org):
@@ -1082,16 +1109,16 @@ To run the test suite, you need [Composer](http://getcomposer.org):
0 commit comments