Skip to content

Commit 766658d

Browse files
committed
Fixing stuff
1 parent 9ea18e5 commit 766658d

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

src/SQLParser/Node/ColRef.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ public function toSql(ConnectionInterface $dbConnection = null, array $parameter
158158
if ($this->table) {
159159
$sql .= NodeFactory::escapeDBItem($this->table, $dbConnection).'.';
160160
}
161-
$sql .= NodeFactory::escapeDBItem($this->column, $dbConnection);
161+
if ($this->column != '*') {
162+
$sql .= NodeFactory::escapeDBItem($this->column, $dbConnection);
163+
} else {
164+
$sql .= '*';
165+
}
162166
if ($this->alias) {
163167
$sql .= ' AS '.$this->alias;
164168
}

src/SQLParser/Query/Select.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444

4545

4646
/**
47-
* This class represents a select Query.
47+
* This class represents a <code>SELECT</code> query. You can use it to generate a SQL query statement
48+
* using the <code>toSql</code> method.
49+
* You can use the <code>QueryResult</code> class if you want to run the query directly.
4850
*
4951
* @author David Négrier <[email protected]>
5052
* @ExtendedAction {"name":"Generate from SQL", "url":"parseselect/", "default":false}

src/views/createQuery.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,32 @@
33
?>
44
<h1>Create a new SQL query</h1>
55

6-
<form action="doCreateQuery" method="post">
6+
<form action="doCreateQuery" method="post" class="form-horizontal">
77
<div class="control-group">
8-
<label class="control-label">Instance name:</label>
8+
<label class="control-label">Instance name*: </label>
99
<div class="controls">
10-
<input type="text" name="name" value="<?php echo plainstring_to_htmlprotected($this->instanceName) ?>" />
10+
<input type="text" name="name" value="<?php echo plainstring_to_htmlprotected($this->instanceName) ?>" required />
11+
<span class="help-block">The name of the <code>Select</code> instance that will be created.</span>
12+
</div>
13+
</div>
14+
15+
<div class="control-group">
16+
<label class="control-label">SQL query*: </label>
17+
<div class="controls">
18+
<textarea rows=10 name="sql" class="span10" required><?php echo plainstring_to_htmlprotected($this->sql) ?></textarea>
19+
<span class="help-block">You can use <strong>parameters</strong> using prepared statement notation. For instance:
20+
<code>select * from users where country_id = :country_id</code></span>
1121
</div>
1222
</div>
1323

14-
15-
<label class="control-label">SQL query:</label>
16-
<textarea rows=10 name="sql" class="span10"><?php echo plainstring_to_htmlprotected($this->sql) ?></textarea>
1724
<div class="control-group">
1825
<div class="controls">
1926
<button name="action" value="parse" type="submit" class="btn btn-danger">Create SQL query object</button>
2027
</div>
2128
</div>
2229

23-
</form>
30+
</form>
31+
32+
<script type="text/javascript">
33+
$(function () { $("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); } );
34+
</script>

0 commit comments

Comments
 (0)