Skip to content

Commit

Permalink
Merge pull request #7 from skipperbent/v3-development
Browse files Browse the repository at this point in the history
Fixed alias method
  • Loading branch information
skipperbent authored Aug 21, 2017
2 parents 0047813 + 0261a31 commit b3d3671
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ public function select($statements)
if (isset($statements['tables'])) {
$tables = [];

foreach ($statements['tables'] as $prefix => $table) {
foreach ($statements['tables'] as $table) {

if (is_numeric($prefix) === false) {
$t = $t = ($table instanceof Raw) ? $prefix : '`' . $prefix . '` AS ' . strtolower($table);
$prefix = isset($statements['aliases'][$table]) ? $statements['aliases'][$table] : null;

if ($prefix !== null) {
$t = ($table instanceof Raw) ? $table : '`' . $table . '` AS ' . strtolower($prefix);
} else {
$t = ($table instanceof Raw) ? $table : '`' . $table . '`';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function query($sql, array $bindings = [])
*/
public function alias($table, $alias)
{
$this->statements['tables'][$this->tablePrefix . $table] = strtolower($alias);
$this->statements['aliases'][$this->tablePrefix . $table] = strtolower($alias);
return $this;
}

Expand Down

0 comments on commit b3d3671

Please sign in to comment.