4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
20 namespace api\v
4\Traits
;
22 trait TableDropperTrait
{
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
;
36 if ($dropTableQuery) {
37 \CRM_Core_DAO
::executeQuery($dropTableQuery);