-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMydbPreparedStatementInterface.php
More file actions
56 lines (48 loc) · 1.63 KB
/
Copy pathMydbPreparedStatementInterface.php
File metadata and controls
56 lines (48 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* This file is part of the sshilko/php-sql-mydb package.
*
* (c) Sergei Shilko <contact@sshilko.com>
*
* MIT License
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* @license https://opensource.org/licenses/mit-license.php MIT
*/
declare(strict_types = 1);
namespace sql;
/**
* Wraps a mysqli prepared statement: bind, execute, fetch all, affected rows,
* insert id and close.
*
* The prepared path is strictly opt-in. Raw query()/command() remain the fast
* path; prepared statements trade a little raw speed for parameterized
* execution and remove the manual escape() responsibility.
*
* @author Sergei Shilko <contact@sshilko.com>
* @license https://opensource.org/licenses/mit-license.php MIT
* @see https://github.com/sshilko/php-sql-mydb
*/
interface MydbPreparedStatementInterface
{
/**
* Bind parameters using mysqli bind_param() type inference:
* int/bool as integer, float as double, everything else as string (null is
* sent as SQL NULL).
*
* @param list<float|int|string|null|bool> $params
*/
public function bind(array $params): bool;
public function execute(): bool;
/**
* Returns the full result set as a list of associative rows, or null when
* the statement produced no result set (for example DML statements).
*
* @psalm-return list<array<array-key, float|int|string|null>>|null
*/
public function fetchAll(): ?array;
public function getAffectedRows(): ?int;
public function getInsertId(): int|string|null;
public function close(): void;
}