- Fixed the QueryBuilder's escaping problem - adapters are now responsible for escaping identifiers.

- Added a MsSQL offset query fragment. There is still a problem with the way the Repository must act within another adapter.
This commit is contained in:
Dave Mc Nicoll committed 2020-04-14 09:47:09 -04:00
1 parent 3ff97f3bf0
commit 026a0f4f83
8 files changed
+75 -26

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
<?php
namespace Ulmus\Query\MsSQL;
class Offset extends \Ulmus\Query\Fragment {
const SQL_TOKEN = "OFFSET %s ROWS FETCH NEXT %s ROWS ONLY";
public int $order = 95;
public int $offset;
public int $limit;
public function set(int $offset, int $limit) : self
{
$this->offset = $offset;
$this->limit = $limit;
return $this;
}
public function render() : string
{
if ( $this->offset < 0 ) {
throw new \Exception("An error occured trying to render the OFFSET fragment ; given value has to be > 0. Received {$this->offset}");
}
if ( $this->limit < 0 ) {
throw new \Exception("An error occured trying to render the LIMIT fragment ; given value has to be > 0. Received {$this->limit}");
}
return $this->renderSegments([
sprintf(static::SQL_TOKEN, $this->offset, $this->limit)
]);
}
}