Skip to content

Commit

Permalink
Add orderBy to QueryBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
cambell-prince committed Dec 2, 2018
1 parent 99e7cab commit cf3547b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/anorm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?php
namespace Anorm\Tools;

define('VERSION', '0.2.2');
define('VERSION', '0.2.3');

// Try 3rd party install relative to bin folder
if (\file_exists(__DIR__ . '/../../../autoload.php')) {
Expand Down
7 changes: 7 additions & 0 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ public function where($sql)
return $this;
}

public function orderBy($sql)
{
$this->ensureFrom();
$this->sql .= ' ORDER BY ' . $sql;
return $this;
}

public function some()
{
$this->ensureFrom();
Expand Down
1 change: 1 addition & 0 deletions test/anorm/DataMapper_Find_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function testFindOne_OK()
public function testFindSome_OK()
{
$generator = DataMapper::find('SomeTableModel', $this->pdo)
->orderBy("name")
->limit(3)
->some();
$i = 0;
Expand Down

0 comments on commit cf3547b

Please sign in to comment.