projects
/
civicrm-core.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
66d736a
)
CRM_Core_DAO - Add helper checkTableHasData()
author
Tim Otten
<totten@civicrm.org>
Wed, 30 Oct 2019 00:20:18 +0000
(17:20 -0700)
committer
Tim Otten
<totten@civicrm.org>
Wed, 30 Oct 2019 00:20:18 +0000
(17:20 -0700)
CRM/Core/DAO.php
patch
|
blob
|
blame
|
history
diff --git
a/CRM/Core/DAO.php
b/CRM/Core/DAO.php
index 0a09592556b1a00074e985c4e1f2dc753725946d..b508b64e6c278a76225998eedfe1e70443aadfd8 100644
(file)
--- a/
CRM/Core/DAO.php
+++ b/
CRM/Core/DAO.php
@@
-1063,6
+1063,18
@@
LIKE %1
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
*