Merge pull request #22665 from colemanw/memberCleanup
[civicrm-core.git] / CRM / Queue / BAO / QueueItem.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * Helpers for managing SQL-backed queue items
20 *
21 * @see CRM_Queue_Queue_Sql
22 */
23 class CRM_Queue_BAO_QueueItem extends CRM_Queue_DAO_QueueItem {
24
25 /**
26 * Ensure that the required SQL table exists.
27 *
28 * @return bool
29 * TRUE if table now exists
30 */
31 public static function findCreateTable() {
32 $checkTableSql = "show tables like 'civicrm_queue_item'";
33 $foundName = CRM_Core_DAO::singleValueQuery($checkTableSql);
34 if ($foundName == 'civicrm_queue_item') {
35 return TRUE;
36 }
37
38 // civicrm/sql/civicrm_queue_item.mysql
39 $fileName = dirname(__FILE__) . '/../../../sql/civicrm_queue_item.mysql';
40
41 $config = CRM_Core_Config::singleton();
42 CRM_Utils_File::sourceSQLFile($config->dsn, $fileName);
43
44 // Make sure it succeeded
45 $foundName = CRM_Core_DAO::singleValueQuery($checkTableSql);
46 return ($foundName == 'civicrm_queue_item');
47 }
48
49 }