问题
I want to create a template for an insert SQL block of code in PHP.
Templates are great to fill in the same value where it is repeated numerous times.
Is it possible to have the live template keep repeating certain blocks of code until I exit the template generation?
For example I want the template to be able to cater for any number of variable in an Insert statement.
It would be great if I can just enter variables until I'm done and the template repeats certain parts until I'm done.
Please look at the following template:
$insert_sql = "INSERT INTO $TABLE$ (`$VAL$`,`$VAL1$`,`$VAL2$`,`$VAL3$`) VALUES (:$VAL$,:$VAL1$,:$VAL2$,:$VAL3$)";
$newq = $dbh->prepare($insert_sql);
$newq->bindParam(":$VAL$", $$$VAL$);
$newq->bindParam(":$VAL1$", $$$VAL1$);
$newq->bindParam(":$VAL2$", $$$VAL2$);
$newq->bindParam(":$VAL3$", $$$VAL3$);
try {
$newq->execute();
} catch (PDOException $e) {
die($insert_sql . "<br/>An SQL error occurred: " . $e->getMessage());
}
$lastid = $dbh->lastInsertId();
来源:https://stackoverflow.com/questions/38883122/phpstorm-live-templates-is-it-possible-to-have-any-number-of-variables