-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
102eb26
commit 5c1ebc1
Showing
6 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
|
||
namespace SQLBuilder\Block; | ||
|
||
|
||
use SQLBuilder\Clause\Having; | ||
use SQLBuilder\Stringable_; | ||
|
||
trait HavingBlock | ||
{ | ||
public function having($expression = null): Having | ||
{ | ||
/** @var Stringable_ $this */ | ||
return new Having($expression, $this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
|
||
namespace SQLBuilder\Clause; | ||
|
||
|
||
use SQLBuilder\Block\LimitBlock; | ||
use SQLBuilder\Helper; | ||
use SQLBuilder\Stringable_; | ||
|
||
class Having extends Condition | ||
{ | ||
const STATEMENT = 'HAVING'; | ||
|
||
public function __toString(): string | ||
{ | ||
return trim($this->parent . ' ' . self::STATEMENT . ' ' . $this->buildExpressions()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Clause; | ||
|
||
use SQLBuilder\Clause\Having; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class HavingTest extends TestCase | ||
{ | ||
|
||
public function testToString() | ||
{ | ||
$having = new Having(); | ||
$having->equal('col',5); | ||
|
||
$this->assertEquals( | ||
'HAVING `col` = 5', | ||
$having->__toString() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters