diff --git a/src/core/Database/PDOStatementProxy.php b/src/core/Database/PDOStatementProxy.php index 532cf65e..6141fe38 100644 --- a/src/core/Database/PDOStatementProxy.php +++ b/src/core/Database/PDOStatementProxy.php @@ -129,7 +129,7 @@ public function setFetchMode(int $mode, ...$args): bool return $this->__object->setFetchMode(...$this->setFetchModeContext); } - public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $length = null, $driver_options = null): bool + public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $length = 0, $driver_options = null): bool { $this->bindParamContext[$parameter] = [$variable, $data_type, $length, $driver_options]; return $this->__object->bindParam($parameter, $variable, $data_type, $length, $driver_options); diff --git a/tests/unit/Database/PDOStatementProxyTest.php b/tests/unit/Database/PDOStatementProxyTest.php index 4a421ccc..2e79d059 100644 --- a/tests/unit/Database/PDOStatementProxyTest.php +++ b/tests/unit/Database/PDOStatementProxyTest.php @@ -90,4 +90,18 @@ public function testSetFetchMode(array $expected, array $args, string $message) self::assertEquals($expected, $stmt->fetchAll(), $message); }); } + + /** + * @covers \Swoole\Database\PDOStatementProxy::bindParam() + */ + public function testBindParam() + { + Coroutine\run(function () { + $stmt = $this->getPdoPool()->get()->prepare('SHOW TABLES like ?'); + $table = 'NON_EXISTING_TABLE_NAME'; + $stmt->bindParam(1, $table, PDO::PARAM_STR); + $stmt->execute(); + self::assertIsArray($stmt->fetchAll()); + }); + } }