@@ -31,7 +31,7 @@ class PDO extends PDOAlias
3131 /**
3232 * @var ClientInterface 数据库客户端
3333 */
34- private readonly ClientInterface $ client ;
34+ public readonly ClientInterface $ client ;
3535
3636 /**
3737 * PDO 构造
@@ -41,10 +41,10 @@ class PDO extends PDOAlias
4141 * @param array|null $options
4242 */
4343 public function __construct (
44- private readonly string $ dsn ,
45- private readonly ?string $ username = null ,
46- private readonly ?string $ password = null ,
47- private ?array $ options = null
44+ public readonly string $ dsn ,
45+ public readonly ?string $ username = null ,
46+ public readonly ?string $ password = null ,
47+ public ?array $ options = []
4848 ) {
4949 $ config = Config::formString ($ this ->dsn , $ this ->username , $ this ->password );
5050 $ this ->client = match (strtolower ($ config ->driver )) {
@@ -70,7 +70,7 @@ public function __destruct()
7070 */
7171 public function prepare (string $ query , array $ options = []): PDOStatementAlias |false
7272 {
73- return new PDOStatement ($ this -> client -> prepare ( $ query), $ this -> options );
73+ return new PDOStatement ($ query, fn () => $ this );
7474 }
7575
7676 /**
@@ -82,7 +82,7 @@ public function prepare(string $query, array $options = []): PDOStatementAlias|f
8282 */
8383 public function query (string $ query , ?int $ fetchMode = null , ...$ fetchModeArgs ): PDOStatementAlias
8484 {
85- return new ResultStatement ( $ this ->client ->query ($ query ), $ this -> options );
85+ return new PDOStatement ( $ query , fn () => $ this , $ this ->client ->query ($ query ));
8686 }
8787
8888 /**
@@ -208,6 +208,7 @@ public function quote(mixed $string, int $type = PDOAlias::PARAM_STR): string|fa
208208 return $ string ? '1 ' : '0 ' ;
209209 case PDOAlias::PARAM_STR :
210210 default :
211+ $ string = (string )$ string ;
211212 $ escaped = '' ;
212213 $ len = strlen ($ string );
213214 for ($ i = 0 ; $ i < $ len ; $ i ++) {
@@ -228,6 +229,7 @@ public function quote(mixed $string, int $type = PDOAlias::PARAM_STR): string|fa
228229 $ escaped .= $ c ;
229230 }
230231 }
232+
231233 return "' $ escaped' " ;
232234 }
233235 }
0 commit comments