Skip to content

Commit

Permalink
- Added depricated alias method (prefix) in QueryBuilderHandler t…
Browse files Browse the repository at this point in the history
…o avoid compability issues.

- Fixed method parameter naming in `alias` method in `QueryBuilderHandler`.
- Renamed `testPrefix` to `testAlias` in `QueryBuilderBehaviorTest` class.
  • Loading branch information
skipperbent committed Apr 29, 2017
1 parent a2328bb commit d7fbd12
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
24 changes: 19 additions & 5 deletions src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,34 @@ public function query($sql, array $bindings = [])
}

/**
* Add table alias
* Add or change table alias
* Example: table AS alias
*
* @see QueryBuilderHandler::addAlias()
* @param string $table
* @param string $prefix
* @param string $alias
* @return QueryBuilderHandler
*/
public function alias($table, $prefix)
public function alias($table, $alias)
{
$this->statements['tables'][$this->tablePrefix . $table] = strtolower($prefix);
$this->statements['tables'][$this->tablePrefix . $table] = strtolower($alias);
return $this;
}

/**
* Add or change table alias
* Example: table AS alias
*
* @deprecated This method will be removed in the near future, please use QueryBuilderHandler::alias instead.
* @see QueryBuilderHandler::alias
* @param string $table
* @param string $alias
* @return QueryBuilderHandler
*/
public function prefix($table, $alias)
{
return $this->alias($table, $alias);
}

/**
* @param $sql
* @param array $bindings
Expand Down
2 changes: 1 addition & 1 deletion tests/Pecee/Pixie/QueryBuilderBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testSelectFlexibility()
);
}

public function testPrefix()
public function testAlias()
{
$query = $this->builder->table(['table1' => 'foo1'])
->alias('table1', 'foo2')
Expand Down

0 comments on commit d7fbd12

Please sign in to comment.