From 08bea26a173c664f08882c0260e0284138ed30e9 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 7 Jun 2019 12:12:24 -0400 Subject: [PATCH] Add WireDatabasePDO tableExists() method --- wire/core/WireDatabasePDO.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wire/core/WireDatabasePDO.php b/wire/core/WireDatabasePDO.php index 1e22e1af..8a43b605 100644 --- a/wire/core/WireDatabasePDO.php +++ b/wire/core/WireDatabasePDO.php @@ -593,6 +593,23 @@ class WireDatabasePDO extends Wire implements WireDatabase { return $tables; } + /** + * Does the given table exist in this database? + * + * #pw-group-custom + * + * @param string $table + * @return bool + * @since 3.0.133 + * + */ + public function tableExists($table) { + $query = $this->prepare('SHOW TABLES LIKE ?'); + $query->execute(array($table)); + $result = $query->fetchColumn(); + return !empty($result); + } + /** * Is the given string a database comparison operator? *