Skip to content

Commit a3ef94c

Browse files
committed
Nullable values for MySQL command parameters
1 parent 25879c1 commit a3ef94c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

berry/mysql/MySQLCommandParameters.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private function Add(int $paramIndex, $value, string $type, $length = NULL): voi
2727
* @param type $value
2828
* @param type $length
2929
*/
30-
public function setString(int $paramIndex, string $value, $length = NULL): void
30+
public function setString(int $paramIndex, ?string $value, $length = NULL): void
3131
{
3232
$this->Add($paramIndex, $value, "s", $length);
3333
}
@@ -38,7 +38,7 @@ public function setString(int $paramIndex, string $value, $length = NULL): void
3838
* @param type $value
3939
* @param type $length
4040
*/
41-
public function setInteger(int $paramIndex, int $value, $length = NULL): void
41+
public function setInteger(int $paramIndex, ?int $value, $length = NULL): void
4242
{
4343
$this->Add($paramIndex, $value, "i", $length);
4444
}
@@ -49,7 +49,7 @@ public function setInteger(int $paramIndex, int $value, $length = NULL): void
4949
* @param type $value
5050
* @param type $length
5151
*/
52-
public function setDouble(int $paramIndex, float $value, $length = NULL): void
52+
public function setDouble(int $paramIndex, ?float $value, $length = NULL): void
5353
{
5454
$this->Add($paramIndex, $value, "d", $length);
5555
}
@@ -74,9 +74,9 @@ public function setBlob(int $paramIndex, $value, $length = NULL): void
7474
* @param type $length
7575
* @return void
7676
*/
77-
public function setDateTime(int $paramIndex, int $secondsSinceUnixEpoch): void
77+
public function setDateTime(int $paramIndex, ?int $secondsSinceUnixEpoch): void
7878
{
79-
$datetime = date("Y-m-d H:i:s", $secondsSinceUnixEpoch);
79+
$datetime = ($secondsSinceUnixEpoch != null) ? date("Y-m-d H:i:s", $secondsSinceUnixEpoch) : null;
8080
$this->Add($paramIndex, $datetime, "s", NULL);
8181
}
8282

0 commit comments

Comments
 (0)