Skip to content

Commit

Permalink
update valueBuilder for string with sign ':' to handle PDO params
Browse files Browse the repository at this point in the history
  • Loading branch information
BMTmohammedtaha committed Sep 25, 2023
1 parent bfa08f7 commit 944eb79
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Build/ValueBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,17 @@ public function convertBinaryToHex($binaryValue): string
return '0x' . base_convert($binaryValue, 2, 16);
}

public function buildString($value)
{
if(strpos($value ,':')){
return $value;
}
if(in_array($value, array_values((new Syntax())->dateFunctions()))){
return "'" . $value . "'";
}
return $value ;
}

/**
* Build an array of formatted values for SQL usage.
*
Expand All @@ -289,7 +300,7 @@ public function build(): array
foreach ($this->defineType() as $value) {
$formattedValues[] = match ($value['type']) {
//handle string or SQL Date Functions
'string' => in_array($value['value'], array_values((new Syntax())->dateFunctions())) ? $value['value'] : "'" . $value['value'] . "'",
'string' => $this->buildString($value['value']),
//handle array as json
'array' => "'" . json_encode($value['value']) . "'",
//handle object as json
Expand Down
2 changes: 2 additions & 0 deletions src/Operations/OperationsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,6 @@ public function whereTable(string $table)
$this->setAttribute('where_table', $table);
return $this;
}


}

0 comments on commit 944eb79

Please sign in to comment.