|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<!-- |
| 3 | + PHP-SQLx Live Templates for PHPStorm/IntelliJ |
| 4 | +
|
| 5 | + Import via: Settings > Editor > Live Templates > Import |
| 6 | +--> |
| 7 | +<templateSet group="PHP-SQLx"> |
| 8 | + <template name="sqlxq" value="$driver->queryAll('$SQL$', [$PARAMS$]);" description="SQLx query with parameters" toReformat="true" toShortenFQNames="true"> |
| 9 | + <variable name="SQL" expression="" defaultValue=""SELECT * FROM table WHERE id = ?i"" alwaysStopAt="true"/> |
| 10 | + <variable name="PARAMS" expression="" defaultValue="""" alwaysStopAt="true"/> |
| 11 | + <context> |
| 12 | + <option name="PHP" value="true"/> |
| 13 | + </context> |
| 14 | + </template> |
| 15 | + |
| 16 | + <template name="sqlxrow" value="$driver->queryRow('$SQL$', [$PARAMS$]);" description="SQLx query single row" toReformat="true" toShortenFQNames="true"> |
| 17 | + <variable name="SQL" expression="" defaultValue=""SELECT * FROM table WHERE id = ?i"" alwaysStopAt="true"/> |
| 18 | + <variable name="PARAMS" expression="" defaultValue="""" alwaysStopAt="true"/> |
| 19 | + <context> |
| 20 | + <option name="PHP" value="true"/> |
| 21 | + </context> |
| 22 | + </template> |
| 23 | + |
| 24 | + <template name="sqlxval" value="$driver->queryValue('$SQL$', [$PARAMS$]);" description="SQLx query single value" toReformat="true" toShortenFQNames="true"> |
| 25 | + <variable name="SQL" expression="" defaultValue=""SELECT COUNT(*) FROM table"" alwaysStopAt="true"/> |
| 26 | + <variable name="PARAMS" expression="" defaultValue="" alwaysStopAt="true"/> |
| 27 | + <context> |
| 28 | + <option name="PHP" value="true"/> |
| 29 | + </context> |
| 30 | + </template> |
| 31 | + |
| 32 | + <template name="sqlxexec" value="$driver->execute('$SQL$', [$PARAMS$]);" description="SQLx execute statement" toReformat="true" toShortenFQNames="true"> |
| 33 | + <variable name="SQL" expression="" defaultValue=""UPDATE table SET col = ?s WHERE id = ?i"" alwaysStopAt="true"/> |
| 34 | + <variable name="PARAMS" expression="" defaultValue="""" alwaysStopAt="true"/> |
| 35 | + <context> |
| 36 | + <option name="PHP" value="true"/> |
| 37 | + </context> |
| 38 | + </template> |
| 39 | + |
| 40 | + <template name="sqlxcond" value="{{ $CONDITION$ }}" description="SQLx conditional block" toReformat="false" toShortenFQNames="true"> |
| 41 | + <variable name="CONDITION" expression="" defaultValue=""AND column = $param"" alwaysStopAt="true"/> |
| 42 | + <context> |
| 43 | + <option name="PHP String" value="true"/> |
| 44 | + </context> |
| 45 | + </template> |
| 46 | + |
| 47 | + <template name="sqlxin" value="$$VAR$ IN :$PARAM$!$TYPE$a" description="SQLx IN clause with typed array" toReformat="false" toShortenFQNames="true"> |
| 48 | + <variable name="VAR" expression="" defaultValue=""id"" alwaysStopAt="true"/> |
| 49 | + <variable name="PARAM" expression="" defaultValue=""ids"" alwaysStopAt="true"/> |
| 50 | + <variable name="TYPE" expression="" defaultValue=""i"" alwaysStopAt="true"/> |
| 51 | + <context> |
| 52 | + <option name="PHP String" value="true"/> |
| 53 | + </context> |
| 54 | + </template> |
| 55 | + |
| 56 | + <template name="sqlxins" value="INSERT INTO $TABLE$ ($COLUMNS$) VALUES ($VALUES$)" description="SQLx INSERT statement" toReformat="false" toShortenFQNames="true"> |
| 57 | + <variable name="TABLE" expression="" defaultValue=""table_name"" alwaysStopAt="true"/> |
| 58 | + <variable name="COLUMNS" expression="" defaultValue=""col1, col2"" alwaysStopAt="true"/> |
| 59 | + <variable name="VALUES" expression="" defaultValue=""?s, ?i"" alwaysStopAt="true"/> |
| 60 | + <context> |
| 61 | + <option name="PHP String" value="true"/> |
| 62 | + </context> |
| 63 | + </template> |
| 64 | + |
| 65 | + <template name="sqlxupd" value="UPDATE $TABLE$ SET $SETS$ WHERE $WHERE$" description="SQLx UPDATE statement" toReformat="false" toShortenFQNames="true"> |
| 66 | + <variable name="TABLE" expression="" defaultValue=""table_name"" alwaysStopAt="true"/> |
| 67 | + <variable name="SETS" expression="" defaultValue=""col1 = ?s, col2 = ?i"" alwaysStopAt="true"/> |
| 68 | + <variable name="WHERE" expression="" defaultValue=""id = ?i"" alwaysStopAt="true"/> |
| 69 | + <context> |
| 70 | + <option name="PHP String" value="true"/> |
| 71 | + </context> |
| 72 | + </template> |
| 73 | + |
| 74 | + <template name="sqlxtx" value="$driver->begin(function($driver) { $CODE$ });" description="SQLx transaction with callback" toReformat="true" toShortenFQNames="true"> |
| 75 | + <variable name="CODE" expression="" defaultValue=""// transaction code"" alwaysStopAt="true"/> |
| 76 | + <context> |
| 77 | + <option name="PHP" value="true"/> |
| 78 | + </context> |
| 79 | + </template> |
| 80 | + |
| 81 | + <template name="sqlxhook" value="$driver->onQuery(function(string $sql, string $sqlInline, float $durationMs) { $CODE$ });" description="SQLx query profiling hook" toReformat="true" toShortenFQNames="true"> |
| 82 | + <variable name="CODE" expression="" defaultValue=""Logger::debug(\"Query took {\$durationMs}ms: {\$sqlInline}\");"" alwaysStopAt="true"/> |
| 83 | + <context> |
| 84 | + <option name="PHP" value="true"/> |
| 85 | + </context> |
| 86 | + </template> |
| 87 | +</templateSet> |
0 commit comments