export
3 months ago
better-backup-v3.php
3 months ago
better-backup.php
3 months ago
better-restore.php
3 months ago
even-better-restore-v3.php
3 months ago
even-better-restore-v4.php
3 months ago
interface-search-replace-repository.php
3 months ago
manager.php
3 months ago
search-replace-processor.php
3 months ago
search-replace-repository.php
3 months ago
search-replace-stack-based.php
3 months ago
search-replace-v2.php
3 months ago
search-replace.php
3 months ago
smart-sort.php
3 months ago
interface-search-replace-repository.php
67 lines
| 1 | <?php |
| 2 | |
| 3 | namespace BMI\Plugin\Database; |
| 4 | |
| 5 | /** |
| 6 | * Interface SearchReplaceRepositoryInterface |
| 7 | * |
| 8 | * Defines the contract for database interactions used in search and replace operations. |
| 9 | * Implementations can use MySQLi, PDO, or WordPress $wpdb. |
| 10 | */ |
| 11 | interface SearchReplaceRepositoryInterface |
| 12 | { |
| 13 | /** |
| 14 | * Escapes a string for safe use in SQL queries. |
| 15 | * |
| 16 | * @param string $string The string to escape. |
| 17 | * @return string The escaped string. |
| 18 | */ |
| 19 | public function escape($string); |
| 20 | |
| 21 | /** |
| 22 | * Retrieves the last error message from the database. |
| 23 | * |
| 24 | * @return string|null The last error message, or null if no error. |
| 25 | */ |
| 26 | public function getLastError(); |
| 27 | |
| 28 | /** |
| 29 | * Retrieves the total row count of a table. |
| 30 | * |
| 31 | * @param string $table The table name. |
| 32 | * @param string|false $primaryKey The primary key column name, or false if none. |
| 33 | * @param string $whereClause Optional WHERE clause to filter rows. |
| 34 | * @return int The total number of rows. |
| 35 | */ |
| 36 | public function getTableRowCount($table, $primaryKey, $whereClause = ''); |
| 37 | |
| 38 | /** |
| 39 | * Retrieves column information for a table. |
| 40 | * |
| 41 | * @param string $table The table name. |
| 42 | * @return array An associative array containing: |
| 43 | * - 'primary_key': The primary key column name (or false). |
| 44 | * - 'auto_increment_primary_key': The auto-increment primary key column name (or false). |
| 45 | * - 'text_columns': An array of column names that are of type char or text. |
| 46 | */ |
| 47 | public function getTableColumnsInfo($table); |
| 48 | |
| 49 | /** |
| 50 | * Fetches rows from the database based on a SQL query. |
| 51 | * |
| 52 | * @param string $sql The SQL query to execute. |
| 53 | * @return array The result rows as associative arrays. |
| 54 | */ |
| 55 | public function fetchRows($sql); |
| 56 | |
| 57 | /** |
| 58 | * Executes a list of queries within a database transaction. |
| 59 | * |
| 60 | * @param array $queries An array of SQL queries to execute. |
| 61 | * @return array An associative array containing: |
| 62 | * - 'updates': The number of successful updates. |
| 63 | * - 'errors': An array of error messages. |
| 64 | */ |
| 65 | public function executeTransaction($queries); |
| 66 | } |
| 67 |