Merge pull request #19936 from jmcclelland/only-include-completed
[civicrm-core.git] / tests / phpunit / api / v4 / Traits / TableDropperTrait.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
6 | |
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 |
10 +--------------------------------------------------------------------+
11 */
12
13 /**
14 *
15 * @package CRM
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 */
18
19
20 namespace api\v4\Traits;
21
22 trait 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 }