+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
+ | Copyright CiviCRM LLC (c) 2004-2020 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* All DAO classes should inherit from this class.
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC (c) 2004-2020
*/
if (!defined('DB_DSN_MODE')) {
return $result;
}
+ /**
+ * Check if a given table has data.
+ *
+ * @param string $tableName
+ * @return bool
+ * TRUE if $tableName has at least one record.
+ */
+ public static function checkTableHasData($tableName) {
+ $c = CRM_Core_DAO::singleValueQuery(sprintf('SELECT count(*) c FROM `%s`', $tableName));
+ return $c > 0;
+ }
+
/**
* @param $version
*
$tr['%' . $key] = $item[0];
}
elseif ($abort) {
- CRM_Core_Error::fatal("{$item[0]} is not of type {$item[1]}");
+ throw new CRM_Core_Exception("{$item[0]} is not of type {$item[1]}");
}
}
}
/**
* Drop all CiviCRM tables.
*
- * @throws \CRM_Exception
+ * @throws \CRM_Core_Exception
*/
public static function dropAllTables() {