Merge pull request #17706 from demeritcowboy/mysql-ssl-alt
[civicrm-core.git] / tests / phpunit / api / v4 / Traits / TableDropperTrait.php
CommitLineData
19b53e5b
C
1<?php
2
380f3545
TO
3/*
4 +--------------------------------------------------------------------+
7d61e75f 5 | Copyright CiviCRM LLC. All rights reserved. |
380f3545 6 | |
7d61e75f
TO
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
380f3545
TO
10 +--------------------------------------------------------------------+
11 */
12
13/**
14 *
15 * @package CRM
ca5cec67 16 * @copyright CiviCRM LLC https://civicrm.org/licensing
380f3545
TO
17 */
18
19
19b53e5b
C
20namespace api\v4\Traits;
21
22trait TableDropperTrait {
23
24 /**
25 * @param $prefix
26 */
27 protected function dropByPrefix($prefix) {
28 $sql = "SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' ) " .
29 "AS statement FROM information_schema.tables " .
30 "WHERE table_name LIKE '%s%%' AND table_schema = DATABASE();";
31 $sql = sprintf($sql, $prefix);
32 $dropTableQuery = \CRM_Core_DAO::executeQuery($sql);
33 $dropTableQuery->fetch();
34 $dropTableQuery = $dropTableQuery->statement;
35
36 if ($dropTableQuery) {
37 \CRM_Core_DAO::executeQuery($dropTableQuery);
38 }
39 }
40
41}