PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.6
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / helpers / wpdb-helper.php

wpdb-helper.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.6, at src/helpers/wpdb-helper.php

45 lines 942 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Helpers;
4
5 use wpdb;
6
7 /**
8 * A helper object for the wpdb.
9 */
10 class Wpdb_Helper {
11
12 /**
13 * The WordPress database instance.
14 *
15 * @var wpdb
16 */
17 private $wpdb;
18
19 /**
20 * Constructs a Wpdb_Helper instance.
21 *
22 * @param wpdb $wpdb The WordPress database instance.
23 */
24 public function __construct( wpdb $wpdb ) {
25 $this->wpdb = $wpdb;
26 }
27
28 /**
29 * Check if table exists.
30 *
31 * @param string $table The table to be checked.
32 *
33 * @return bool Whether the table exists.
34 */
35 public function table_exists( $table ) {
36 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Reason: There is no unescaped user input.
37 $table_exists = $this->wpdb->get_var( "SHOW TABLES LIKE '{$table}'" );
38 if ( \is_wp_error( $table_exists ) || \is_null( $table_exists ) ) {
39 return false;
40 }
41
42 return true;
43 }
44 }
45