File tree Expand file tree Collapse file tree 1 file changed +0
-28
lines changed Expand file tree Collapse file tree 1 file changed +0
-28
lines changed Original file line number Diff line number Diff line change @@ -135,34 +135,6 @@ into the SQL query. You should use classic SQL parameters for this. This means t
135
135
136
136
Want to know more? <a class =" btn btn-primary btn-large " href =" doc/magic_twig.md " >Check out the MagicTwig guide!</a >
137
137
138
- <a name =" twig " ></a >
139
- Use Twig templating in your SQL queries!
140
- ----------------------------------------
141
-
142
- Discarding unused parameters and auto-joining keys is not enough? You have very specific needs? Say hello to
143
- Twig integration!
144
-
145
- Using Twig integration, you can directly add Twig conditions right into your SQL.
146
-
147
- ``` php
148
- use Mouf\Database\MagicQuery;
149
-
150
- $sql = "SELECT users.* FROM users {% if isAdmin %} WHERE users.admin = 1 {% endif %}";
151
-
152
- $magicQuery = new MagicQuery();
153
- // By default, Twig integration is disabled. You need to enable it.
154
- $magicQuery->setEnableTwig(true);
155
-
156
- $completeSql = $magicQuery->build($sql, ['isAdmin' => true]);
157
- // Parameters are passed to the Twig SQL query, and the SQL query is returned.
158
- ```
159
-
160
- <div class =" alert alert-info " ><strong >Heads up!</strong > The Twig integration cannot be used to insert parameters
161
- into the SQL query. You should use classic SQL parameters for this. This means that instead if writing
162
- <code >{{ id }}</code >, you should write <code >: id </code >.</div >
163
-
164
- Want to know more? <a class =" btn btn-primary " href =" doc/magic_twig.md " >Check out the MagicTwig guide!</a >
165
-
166
138
Is it a MySQL only tool?
167
139
------------------------
168
140
You can’t perform that action at this time.
0 commit comments