PluginProbe
404 Solution / trunk
404 Solution vtrunk
4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.1.7 4.1.6 4.1.5 4.1.4 4.1.3 trunk 2.30.0 All 109 releases
404-solution / includes / database / DatabaseQueryInterface.php

DatabaseQueryInterface.php in 404 Solution trunk, at includes/database/DatabaseQueryInterface.php

65 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) {
4 exit;
5 }
6
7 /**
8 * The centralized query pipeline every DAO uses: the error-handling
9 * queryAndGetResults wrapper, the scalar-int helper, table-name placeholder
10 * replacement, and the transaction harness with deadlock retry.
11 */
12 interface ABJ_404_Solution_DatabaseQueryInterface {
13
14 /**
15 * Execute a SQL query with full error handling, retry, and recovery.
16 *
17 * @param string $query SQL query (may contain {wp_*} table placeholders).
18 * @param array<string, mixed> $options {
19 * @type bool $log_errors Log errors (default true).
20 * @type bool $log_too_slow Log slow queries (default true).
21 * @type array $ignore_errors Error substrings to suppress.
22 * @type array $query_params Parameters for wpdb::prepare().
23 * @type bool $skip_repair Skip missing-table auto-repair.
24 * @type string $result_type ARRAY_A or OBJECT.
25 * @type int $timeout Query timeout in seconds (0 = default 60s).
26 * }
27 * @return array<string, mixed> {
28 * @type array $rows Result rows (empty array on non-SELECT).
29 * @type string $last_error MySQL error string ('' on success).
30 * @type array $last_result wpdb last_result.
31 * @type int $rows_affected Rows affected.
32 * @type int $insert_id Last INSERT ID.
33 * @type float $elapsed_time Seconds elapsed.
34 * @type bool $timed_out True when query timed out.
35 * }
36 */
37 public function queryAndGetResults($query, $options = array()): array;
38
39 /**
40 * Execute a SELECT query that returns a single scalar value as int.
41 *
42 * @param string $query
43 * @param array<string, mixed> $options
44 * @return int
45 */
46 public function queryScalarInt($query, $options = array()): int;
47
48 /**
49 * Replace {wp_*} table-name placeholders with actual prefixed names.
50 *
51 * @param string $query
52 * @return string
53 */
54 public function doTableNameReplacements($query): string;
55
56 /**
57 * Execute an array of SQL statements as a single transaction with deadlock retry.
58 *
59 * @param array<int, string> $statementArray
60 * @return void
61 * @throws \Exception on non-retryable failure.
62 */
63 public function executeAsTransaction(array $statementArray): void;
64 }
65