Currently there are two ways to do this:
Your flow is interrupted even more because you are constantly having to translate
First of all, the formatting required by a SQL tool is different from what is required by a code editor.
For example, the query
SELECT person.id, person.lastname, person.firstname, person.city, person.state, person.zip FROM person WHERE person.lastname LIKE '%ouvering%'
needs to be represented in PHP as
$sql = "SELECT person.id, person.lastname, person.firstname, " . "person.city, person.state, person.zip " . "FROM person " . "WHERE person.lastname LIKE '%ouvering%'";
There is also the problem of substitution variables. The more likely way you would see the above query string in PHP would be either using a PHP substitution variable, or using a MYSQL prepared statement:
Substitution variable
$sql = "SELECT person.id, person.lastname, person.firstname, " . "person.city, person.state, person.zip " . "FROM person " . "WHERE person.lastname LIKE '%" . mysql_real_escape_string($lastname) . "%'";
Prepared statement
$stmt = $mysqli->stmt_init();
$sql = SELECT person.id, person.lastname, person.firstname, " .
"person.city, person.state, person.zip " .
"FROM person " .
"WHERE person.lastname LIKE ?";
if ($stmt->prepare($sql)) {
$stmt->bind_param("s", $lastname );
/* execute query */
$stmt->execute();
This means that when you copy and paste, you have to put in values for the substitution variables, and then when you paste back into the editor, you have to re-convert. A number of folks have complained about this on the user list, and Wade Chandler has even built a plugin that converts back and forth between Java and text.
Wade's plugin solves part of the problem, but it doesn't really handle the issue of substitution variables.
This feature significantly improves the flow and productivity for developers (PHP initially) by letting them quickly run an action to test a query. It would be implemented as a plugin module that works with the PHP editor.
The editor toolbar will show a new item that displays the current connection, much like what is available in the SQL editor today. Initially it is empty, but the user can select it, and it is a drop-down of all available connections.
This allows the user to associate a particular connection with the current file, which is useful for this operation as well as other potential database-related operations.
----------------------------------------------------------- | Connection: _____________________________V | | | | Please enter values for query parameters | | | | param1 : ____________ | | param2 : ____________ | | | | [Cancel] [Test Query] | ----------------------------------------------------------
------------------------------------------------------ | | | The query was modified, do you want to update the | | selected query string? | | | | [No] [Yes] | ------------------------------------------------------