- 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:
1 parent
3ff97f3bf0
commit
026a0f4f83
8 files changed
+75
-26
No files matched your search
@@ -7,7 +7,8 @@ use PDO,
|
||||
|
||||
class PdoObject extends PDO {
|
||||
|
||||
public function select(string $sql, array $parameters = []): PDOStatement {
|
||||
public function select(string $sql, array $parameters = []): PDOStatement
|
||||
{
|
||||
try {
|
||||
if (false !== ( $statement = $this->prepare($sql) )) {
|
||||
$statement = $this->execute($statement, $parameters, false);
|
||||
@@ -21,7 +22,8 @@ class PdoObject extends PDO {
|
||||
}
|
||||
}
|
||||
|
||||
public function runQuery(string $sql, array $parameters = []): ? PDOStatement {
|
||||
public function runQuery(string $sql, array $parameters = []): ? PDOStatement
|
||||
{
|
||||
try {
|
||||
if (false !== ( $statement = $this->prepare($sql) )) {
|
||||
return $this->execute($statement, $parameters, true);
|
||||
@@ -34,7 +36,8 @@ class PdoObject extends PDO {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function execute(PDOStatement $statement, array $parameters = [], bool $commit = true): ? PDOStatement {
|
||||
public function execute(PDOStatement $statement, array $parameters = [], bool $commit = true): ? PDOStatement
|
||||
{
|
||||
try {
|
||||
if ( ! $this->inTransaction() ) {
|
||||
$this->beginTransaction();
|
||||
@@ -56,10 +59,9 @@ class PdoObject extends PDO {
|
||||
catch (\PDOException $e) {
|
||||
$this->rollback();
|
||||
|
||||
throw new \PdoException($e->getMessage() . " `$sql` with data:" . json_encode($parameters));
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-6
@@ -44,17 +44,13 @@ abstract class Sql {
|
||||
{
|
||||
switch(true) {
|
||||
case is_object($value):
|
||||
# @TODO Make sure the object is a Field
|
||||
return (string) $value;
|
||||
break;
|
||||
|
||||
case is_string($value):
|
||||
$value = "\"$value\"";
|
||||
break;
|
||||
return "'$value'";
|
||||
|
||||
case is_null($value):
|
||||
$value = "NULL";
|
||||
break;
|
||||
return "NULL";
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
Reference in new issue
Block a user