本文整理汇总了PHP中CRM_Core_DAO::checkTableExists方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO::checkTableExists方法的具体用法?PHP CRM_Core_DAO::checkTableExists怎么用?PHP CRM_Core_DAO::checkTableExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_DAO
的用法示例。
在下文中一共展示了CRM_Core_DAO::checkTableExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verifyPreDBState
function verifyPreDBState(&$errorMessage)
{
$latestVer = CRM_Utils_System::version();
$errorMessage = ts('Pre-condition failed for upgrade to %1.', array(1 => $latestVer));
// check table, if the db is 3.1
if (CRM_Core_DAO::checkTableExists('civicrm_acl_contact_cache')) {
$errorMessage = ts("Database check failed - it looks like you have already upgraded to the latest version (v%1) of the database. OR If you think this message is wrong, it is very likely that this a partially upgraded db and you will need to reload the correct db on which upgrade was never tried.", array(1 => $latestVer));
return false;
}
// check table-column, if the db is 3.1
if (CRM_Core_DAO::checkFieldExists('civicrm_custom_field', 'date_format')) {
$errorMessage = ts("Database check failed - it looks like you have already upgraded to the latest version (v%1) of the database. OR If you think this message is wrong, it is very likely that this a partially upgraded db and you will need to reload the correct db on which upgrade was never tried.", array(1 => $latestVer));
return false;
}
//check previous version table e.g 3.0.*
if (!CRM_Core_DAO::checkTableExists('civicrm_participant_status_type') || !CRM_Core_DAO::checkTableExists('civicrm_navigation')) {
$errorMessage .= ' Few important tables were found missing.';
return false;
}
// check fields which MUST be present if a proper 3.0.* db
if (!CRM_Core_DAO::checkFieldExists('civicrm_relationship_type', 'label_a_b') || !CRM_Core_DAO::checkFieldExists('civicrm_mapping_field', 'im_provider_id') || !CRM_Core_DAO::checkFieldExists('civicrm_contact', 'email_greeting_id')) {
// db looks to have stuck somewhere between 2.2 & 3.0
$errorMessage .= ' Few important fields were found missing in some of the tables.';
return false;
}
return true;
}
示例2: verifyPreDBState
/**
* @param $errorMessage
*
* @return bool
*/
function verifyPreDBState(&$errorMessage)
{
$errorMessage = ts('Pre-condition failed for upgrade step %1.', array(1 => '4'));
if (CRM_Core_DAO::checkTableExists('civicrm_event_page')) {
return FALSE;
}
// check fields which MUST be present if a proper 2.2 db
if (!CRM_Core_DAO::checkFieldExists('civicrm_event', 'intro_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_title') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_email_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_email_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_from_name') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_from_email') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'cc_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'bcc_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'default_fee_id') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'default_discount_id') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_title') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_pay_later') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'pay_later_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'pay_later_receipt') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_multiple_registrations')) {
// db looks to have stuck somewhere between 2.1 & 2.2
$errorMessage .= ' Few important fields were found missing in some of the tables.';
return FALSE;
}
if ($this->checkVersion('2.1.103')) {
$this->setVersion('2.2');
} else {
return FALSE;
}
// update config defaults
$domain = new CRM_Core_DAO_Domain();
$domain->selectAdd();
$domain->selectAdd('config_backend');
$domain->find(TRUE);
if ($domain->config_backend) {
$defaults = unserialize($domain->config_backend);
// reset components
$defaults['enableComponents'] = array('CiviContribute', 'CiviPledge', 'CiviMember', 'CiviEvent', 'CiviMail');
$defaults['enableComponentIDs'] = array(1, 6, 2, 3, 4);
$defaults['moneyvalueformat'] = '%!i';
$defaults['fieldSeparator'] = ',';
$defaults['fatalErrorTemplate'] = 'CRM/common/fatal.tpl';
// serialise settings
CRM_Core_BAO_ConfigSetting::add($defaults);
}
return $this->checkVersion('2.2');
}
示例3: verifyPreDBState
function verifyPreDBState(&$errorMessage)
{
$errorMessage = ts('Pre-condition failed for upgrade to 2.1.2.');
// check if the db is 2.2
if (!CRM_Core_DAO::checkTableExists('civicrm_event_page') && CRM_Core_DAO::checkTableExists('civicrm_pcp_block') && CRM_Core_DAO::checkTableExists('civicrm_pcp') && CRM_Core_DAO::checkTableExists('civicrm_contribution_soft')) {
$errorMessage = ts('Database check failed - it looks like you have already upgraded to the latest version (v2.2) of the database.');
return false;
}
// check if the db is 2.2
if (CRM_Core_DAO::checkFieldExists('civicrm_participant', 'registered_by_id') && CRM_Core_DAO::checkFieldExists('civicrm_event', 'intro_text') && CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_multiple_registrations') && CRM_Core_DAO::checkFieldExists('civicrm_pcp_block', 'tellfriend_limit') && CRM_Core_DAO::checkFieldExists('civicrm_pcp_block', 'supporter_profile_id') && CRM_Core_DAO::checkFieldExists('civicrm_pcp', 'status_id') && CRM_Core_DAO::checkFieldExists('civicrm_pcp', 'goal_amount') && CRM_Core_DAO::checkFieldExists('civicrm_contribution_soft', 'pcp_display_in_roll') && CRM_Core_DAO::checkFieldExists('civicrm_contribution_soft', 'amount')) {
$errorMessage = ts('Database check failed - it looks like you have already upgraded to the latest version (v2.2) of the database.');
return false;
}
if (!CRM_Core_DAO::checkTableExists('civicrm_cache') || !CRM_Core_DAO::checkTableExists('civicrm_group_contact_cache') || !CRM_Core_DAO::checkTableExists('civicrm_menu') || !CRM_Core_DAO::checkTableExists('civicrm_discount') || !CRM_Core_DAO::checkTableExists('civicrm_pledge') || !CRM_Core_DAO::checkTableExists('civicrm_pledge_block') || !CRM_Core_DAO::checkTableExists('civicrm_pledge_payment')) {
$errorMessage .= ' Few important tables were found missing.';
return false;
}
// check fields which MUST be present if a proper 2.1 db
if (!CRM_Core_DAO::checkFieldExists('civicrm_cache', 'group_name') || !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'created_date') || !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'expired_date') || !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'option_group_id') || !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'end_date') || !CRM_Core_DAO::checkFieldExists('civicrm_group_contact_cache', 'contact_id') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'path_arguments') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'is_exposed') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'page_type') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'component_id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'name')) {
// db looks to have stuck somewhere between 2.0 & 2.1
$errorMessage .= ' Few important fields were found missing in some of the tables.';
return false;
}
return true;
}
示例4: verifyPreDBState
function verifyPreDBState(&$errorMessage)
{
$latestVer = CRM_Utils_System::version();
$errorMessage = ts('Pre-condition failed for upgrade to %1.', array(1 => $latestVer));
// check table, if the db is 3.0
if (CRM_Core_DAO::checkTableExists('civicrm_navigation') && CRM_Core_DAO::checkTableExists('civicrm_participant_status_type')) {
$errorMessage = ts("Database check failed - it looks like you have already upgraded to the latest version (v%1) of the database. OR If you think this message is wrong, it is very likely that this a partially upgraded db and you will need to reload the correct db on which upgrade was never tried.", array(1 => $latestVer));
return false;
}
// check table-column, if the db is 3.0
if (CRM_Core_DAO::checkFieldExists('civicrm_menu', 'domain_id') && CRM_Core_DAO::checkFieldExists('civicrm_event', 'created_id') && CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_template') && CRM_Core_DAO::checkFieldExists('civicrm_uf_field', 'is_reserved') && CRM_Core_DAO::checkFieldExists('civicrm_contact', 'email_greeting_id') && CRM_Core_DAO::checkFieldExists('civicrm_payment_processor_type', 'payment_type')) {
$errorMessage = ts("Database check failed - it looks like you have already upgraded to the latest version (v%1) of the database. OR If you think this message is wrong, it is very likely that this a partially upgraded db and you will need to reload the correct db on which upgrade was never tried.", array(1 => $latestVer));
return false;
}
//check previous version table e.g 2.2.*
if (!CRM_Core_DAO::checkTableExists('civicrm_cache') || !CRM_Core_DAO::checkTableExists('civicrm_pcp_block') || !CRM_Core_DAO::checkTableExists('civicrm_menu') || !CRM_Core_DAO::checkTableExists('civicrm_discount') || !CRM_Core_DAO::checkTableExists('civicrm_pcp') || !CRM_Core_DAO::checkTableExists('civicrm_pledge_block') || !CRM_Core_DAO::checkTableExists('civicrm_contribution_soft')) {
$errorMessage .= ' Few important tables were found missing.';
return false;
}
// check fields which MUST be present if a proper 2.2.* db
if (!CRM_Core_DAO::checkFieldExists('civicrm_activity', 'due_date_time') || !CRM_Core_DAO::checkFieldExists('civicrm_contact', 'greeting_type_id') || !CRM_Core_DAO::checkFieldExists('civicrm_contribution', 'check_number')) {
// db looks to have stuck somewhere between 2.1 & 2.2
$errorMessage .= ' Few important fields were found missing in some of the tables.';
return false;
}
return true;
}
示例5: buildQuickForm
function buildQuickForm()
{
require_once 'UK_Direct_Debit/Form/Main.php';
// If no civicrm_sd, then create that table
if (!CRM_Core_DAO::checkTableExists('civicrm_sd')) {
$creatSql = "CREATE TABLE `civicrm_sd` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `start_date` datetime NOT NULL,\n `frequency_unit` enum('day','week','month','year') CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT 'month',\n `frequency_interval` int(10) unsigned DEFAULT NULL,\n\t\t\t\t\t`amount` decimal(20,2) DEFAULT NULL,\n `transaction_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,\n `contact_id` int(10) unsigned DEFAULT NULL,\n `external_id` int(10) unsigned DEFAULT NULL,\n `membership_id` int(10) unsigned DEFAULT NULL,\n `member_count` int(10) unsigned DEFAULT NULL,\n `payment_processor_id` varchar(255) DEFAULT NULL,\n `payment_instrument_id` int(10) unsigned DEFAULT NULL,\n `cycle_day` int(10) unsigned NOT NULL DEFAULT '1',\n `contribution_status_id` int(10) DEFAULT '1',\n `is_valid` int(4) NOT NULL DEFAULT '1',\n `payerReference` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,\n\t `recur_id` int(10) unsigned DEFAULT NULL,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB AUTO_INCREMENT=350 DEFAULT CHARSET=latin1";
CRM_Core_DAO::executeQuery($creatSql);
$columnExists = CRM_Core_DAO::checkFieldExists('civicrm_contribution_recur', 'membership_id');
if (!$columnExists) {
$query = "\n ALTER TABLE civicrm_contribution_recur\n ADD membership_id int(10) unsigned AFTER contact_id,\n ADD CONSTRAINT FK_civicrm_contribution_recur_membership_id\n FOREIGN KEY(membership_id) REFERENCES civicrm_membership(id) ON DELETE CASCADE ON UPDATE RESTRICT";
CRM_Core_DAO::executeQuery($query);
}
} else {
$emptySql = "TRUNCATE TABLE `civicrm_sd`";
CRM_Core_DAO::executeQuery($emptySql);
}
$smartDebitArray = self::getSmartDebitPayments(NULL);
foreach ($smartDebitArray as $key => $smartDebitRecord) {
if ($smartDebitRecord['current_state'] == 10 || $smartDebitRecord['current_state'] == 1 || $smartDebitRecord['current_state'] == 11) {
$regularAmount = substr($smartDebitRecord['regular_amount'], 2);
// Extract the number from reference_number
$output = preg_match("/\\d+/", $smartDebitRecord['reference_number'], $results);
if ($regularAmount && $results[0]) {
list($y, $m, $d) = explode('-', $smartDebitRecord['start_date']);
$sql = "INSERT INTO `civicrm_sd`(`start_date`, `frequency_unit`, `amount`, `transaction_id`, `external_id`, `payment_processor_id`, `payment_instrument_id`, `cycle_day`, `contribution_status_id`, `frequency_interval`, `payerReference`) VALUES (%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11)";
$params = array(1 => array($smartDebitRecord['start_date'], 'String'), 2 => array(self::translateSmartDebitFrequencyUnit($smartDebitRecord['frequency_type']), 'String'), 3 => array($regularAmount, 'Float'), 4 => array($smartDebitRecord['reference_number'], 'String'), 5 => array($results[0], 'Int'), 6 => array(self::getSmartDebitPaymentProcessorID(), 'Int'), 7 => array(5, 'Int'), 8 => array($d, 'Int'), 9 => array(5, 'Int'), 10 => array($smartDebitRecord['frequency_factor'], 'Int'), 11 => array($smartDebitRecord['payerReference'], 'String'));
CRM_Core_DAO::executeQuery($sql, $params);
}
}
}
if ($smartDebitArray) {
CRM_Core_Session::setStatus('Smart debit data retreived successfully.', 'Success', 'info');
}
}
示例6: check
/**
* Check whether the install has run before.
*
* Circa v4.7.betaX, we introduced a new mechanism for tracking installation
* and firing a post-install event. However, it's fairly difficult to test the
* edge-cases directly, so this canary should fire if there are any problems
* in the design/implementation of the installation-tracker.
*
* This should not exist. It should be removed in a future version.
*
* @param \Civi\Core\Event\SystemInstallEvent $event
* @throws \CRM_Core_Exception
*/
public static function check(SystemInstallEvent $event)
{
if (\CRM_Core_DAO::checkTableExists('civicrm_install_canary')) {
throw new \CRM_Core_Exception("Found installation canary. This suggests that something went wrong with tracking installation process. Please post to forum or JIRA.");
}
\Civi::log()->info('Creating canary table');
\CRM_Core_DAO::executeQuery('CREATE TABLE civicrm_install_canary (id int(10) unsigned NOT NULL)');
}
示例7: verifyPreDBState
function verifyPreDBState(&$errorMessage)
{
// check if log file is writable
$config = CRM_Core_Config::singleton();
if (!is_writable($config->uploadDir . 'CiviCRM.log') && !is_writable($config->uploadDir . 'CiviCRM.log.' . md5($config->dsn . $config->userFrameworkResourceURL))) {
$errorMessage = ts('Log file CiviCRM.log is not writable. Make sure files directory is writable.', array(1 => $config->uploadDir));
return false;
}
$errorMessage = ts('Database check failed - the current database is not v2.1.');
$is21db = true;
// abort if partial upgraded db found.
if ($this->checkVersion('2.1.101') || $this->checkVersion('2.1.102') || $this->checkVersion('2.1.103')) {
$errorMessage = ts('Corrupt / Partial Upgraded database found. Looks like upgrade wizard failed to complete all the required steps to convert your database to v2.2. Please fix any errors and start the upgrade process again with a clean v2.1 database.');
return false;
}
// abort if already 2.2
if ($this->checkVersion('2.2')) {
$errorMessage = ts('Database check failed - looks like you have already upgraded to the latest version (v2.2) of the database.');
return false;
}
// check if 2.1 version
if (!$this->checkVersion('2.1.2') || !$this->checkVersion('2.1.3') || !$this->checkVersion('2.1.4')) {
$is21db = false;
}
// check if 2.1 tables exists
if (!CRM_Core_DAO::checkTableExists('civicrm_pledge') || !CRM_Core_DAO::checkTableExists('civicrm_cache') || !CRM_Core_DAO::checkTableExists('civicrm_group_contact_cache') || !CRM_Core_DAO::checkTableExists('civicrm_discount') || !CRM_Core_DAO::checkTableExists('civicrm_menu') || !CRM_Core_DAO::checkTableExists('civicrm_pledge') || !CRM_Core_DAO::checkTableExists('civicrm_pledge_block') || !CRM_Core_DAO::checkTableExists('civicrm_case_contact')) {
// db is not 2.1
$errorMessage .= ' Few 2.1 tables were found missing.';
$is21db = false;
}
// check fields which MUST be present if a proper 2.1 db
if ($is21db) {
if (!CRM_Core_DAO::checkFieldExists('civicrm_contribution_page', 'is_recur_interval') || !CRM_Core_DAO::checkFieldExists('civicrm_contribution_page', 'recur_frequency_unit') || !CRM_Core_DAO::checkFieldExists('civicrm_contribution_page', 'for_organization') || !CRM_Core_DAO::checkFieldExists('civicrm_contribution_page', 'is_for_organization') || !CRM_Core_DAO::checkFieldExists('civicrm_contribution', 'is_pay_later') || !CRM_Core_DAO::checkFieldExists('civicrm_membership', 'is_pay_later') || !CRM_Core_DAO::checkFieldExists('civicrm_membership_status', 'is_reserved') || !CRM_Core_DAO::checkFieldExists('civicrm_participant', 'is_pay_later') || !CRM_Core_DAO::checkFieldExists('civicrm_participant', 'fee_amount') || !CRM_Core_DAO::checkFieldExists('civicrm_participant', 'registered_by_id') || !CRM_Core_DAO::checkFieldExists('civicrm_participant', 'discount_id') || !CRM_Core_DAO::checkFieldExists('civicrm_contact', 'employer_id') || !CRM_Core_DAO::checkFieldExists('civicrm_domain', 'locales') || !CRM_Core_DAO::checkFieldExists('civicrm_mapping', 'mapping_type_id') || !CRM_Core_DAO::checkFieldExists('civicrm_custom_field', 'is_view') || !CRM_Core_DAO::checkFieldExists('civicrm_group', 'cache_date') || !CRM_Core_DAO::checkFieldExists('civicrm_group', 'parents') || !CRM_Core_DAO::checkFieldExists('civicrm_group', 'children') || !CRM_Core_DAO::checkFieldExists('civicrm_preferences', 'editor_id') || !CRM_Core_DAO::checkFieldExists('civicrm_uf_group', 'group_type') || !CRM_Core_DAO::checkFieldExists('civicrm_address', 'name') || !CRM_Core_DAO::checkFieldExists('civicrm_uf_match', 'language')) {
// db looks to have stuck somewhere between 2.1 & 2.2
$errorMessage .= ' Few important fields were found missing in some of the tables.';
$is21db = false;
}
}
// check if the db is 2.2
if (!CRM_Core_DAO::checkTableExists('civicrm_event_page') && CRM_Core_DAO::checkFieldExists('civicrm_participant', 'registered_by_id') && CRM_Core_DAO::checkFieldExists('civicrm_event', 'intro_text') && CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_multiple_registrations') && CRM_Core_DAO::checkTableExists('civicrm_pcp_block') && CRM_Core_DAO::checkFieldExists('civicrm_pcp_block', 'tellfriend_limit') && CRM_Core_DAO::checkFieldExists('civicrm_pcp_block', 'supporter_profile_id') && CRM_Core_DAO::checkTableExists('civicrm_pcp') && CRM_Core_DAO::checkFieldExists('civicrm_pcp', 'status_id') && CRM_Core_DAO::checkFieldExists('civicrm_pcp', 'goal_amount') && CRM_Core_DAO::checkTableExists('civicrm_contribution_soft') && CRM_Core_DAO::checkFieldExists('civicrm_contribution_soft', 'pcp_display_in_roll') && CRM_Core_DAO::checkFieldExists('civicrm_contribution_soft', 'amount')) {
$errorMessage = ts('Database check failed - it looks like you have already upgraded to the latest version (v2.2) of the database.');
return false;
}
// check tables which should not exist for v2.x
if (CRM_Core_DAO::checkTableExists('civicrm_custom_option') || CRM_Core_DAO::checkTableExists('civicrm_custom_value') || CRM_Core_DAO::checkTableExists('civicrm_email_history') || CRM_Core_DAO::checkTableExists('civicrm_geo_coord') || CRM_Core_DAO::checkTableExists('civicrm_individual') || CRM_Core_DAO::checkTableExists('civicrm_location') || CRM_Core_DAO::checkTableExists('civicrm_meeting') || CRM_Core_DAO::checkTableExists('civicrm_organization') || CRM_Core_DAO::checkTableExists('civicrm_phonecall') || CRM_Core_DAO::checkTableExists('civicrm_sms_history') || CRM_Core_DAO::checkTableExists('civicrm_validation')) {
// table(s) found in the db which are no longer required
// for v2.x, though would not do any harm it's recommended
// to remove them.
CRM_Core_Session::setStatus(ts("Table(s) found in your db which are no longer required for v2.x, though would not do any harm it's recommended to remove them"));
}
// show error if any of the tables, use 'MyISAM' storage engine.
// just check the first 10 civicrm tables, rather than checking all 106!
if (CRM_Core_DAO::isDBMyISAM(10)) {
$errorMessage = ts('Your database is configured to use the MyISAM database engine. CiviCRM requires InnoDB. You will need to convert any MyISAM tables in your database to InnoDB before proceeding.');
return false;
}
return true;
}
示例8: install
/**
* Add column to table on install
*/
public function install()
{
if (CRM_Core_DAO::checkTableExists('civicrm_contact_segment')) {
if (!CRM_Core_DAO::checkFieldExists('civicrm_contact_segment', 'is_main')) {
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_contact_segment\n ADD COLUMN is_main TINYINT(3) NULL DEFAULT 0 AFTER is_active");
}
} else {
throw new Exception('This extension requires table civicrm_contact_segment
(extension org.civicoop.contactsegment), could not find this table!');
}
}
示例9: deleteWithId
/**
* Function to delete a condition with id
*
* @param int $conditionId
* @throws Exception when conditionId is empty
* @access public
* @static
*/
public static function deleteWithId($conditionId)
{
if (empty($conditionId)) {
throw new Exception('condition id can not be empty when attempting to delete a civirule condition');
}
if (!CRM_Core_DAO::checkTableExists(self::getTableName())) {
return;
}
//delete rows from rule_condition to prevent a foreign key constraint error
CRM_Core_DAO::executeQuery("DELETE FROM `civirule_rule_condition` where `condition_id` = %1", array(1 => array($conditionId, 'Integer')));
$condition = new CRM_Civirules_BAO_Condition();
$condition->id = $conditionId;
$condition->delete();
return;
}
示例10: verifyPostDBState
function verifyPostDBState(&$errorMessage)
{
// check if civicrm_event_page tables droped
if (CRM_Core_DAO::checkTableExists('civicrm_event_page')) {
$errorMessage .= ' civicrm_event_page table is not droped.';
return false;
}
// check fields which MUST be present civicrm_event
if (!CRM_Core_DAO::checkFieldExists('civicrm_event', 'intro_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_title') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_email_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_email_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_from_name') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_from_email') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'cc_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'bcc_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'default_fee_id') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'default_discount_id') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_title') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_pay_later') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'pay_later_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'pay_later_receipt') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_multiple_registrations')) {
$errorMessage .= ' Few important fields were found missing in civicrm_event table.';
return false;
}
$errorMessage = ts('Post-condition failed for upgrade step %1.', array(1 => '2'));
return $this->checkVersion('2.1.102');
}
示例11: rewriteContactIds
public static function rewriteContactIds()
{
$contractTable = CRM_Core_DAO::checkTableExists('civicrm_hrjobcontract');
$datesTable = CRM_Core_DAO::checkTableExists('civicrm_value_jobcontract_dates_13');
if (!$contractTable || !$datesTable) {
return false;
}
$dates = CRM_Core_DAO::executeQuery('SELECT id, contract_id FROM civicrm_value_jobcontract_dates_13 ORDER BY id ASC');
while ($dates->fetch()) {
$contract = CRM_Core_DAO::executeQuery('SELECT contact_id FROM civicrm_hrjobcontract WHERE id = %1', array(1 => array($dates->contract_id, 'Integer')));
if ($contract->fetch()) {
CRM_Core_DAO::executeQuery('UPDATE civicrm_value_jobcontract_dates_13 SET entity_id = %1 WHERE id = %2', array(1 => array($contract->contact_id, 'Integer'), 2 => array($dates->id, 'Integer')));
}
}
return true;
}
示例12: verifyPostDBState
function verifyPostDBState(&$errorMessage)
{
if (!CRM_Core_DAO::checkTableExists('civicrm_cache') || !CRM_Core_DAO::checkTableExists('civicrm_discount') || !CRM_Core_DAO::checkTableExists('civicrm_group_contact_cache') || !CRM_Core_DAO::checkTableExists('civicrm_menu')) {
// db is not 2.1
$errorMessage .= ' Few 2.1 tables were found missing.';
return false;
}
// check fields which MUST be present if a proper 2.1 db
if (!CRM_Core_DAO::checkFieldExists('civicrm_cache', 'group_name') || !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'created_date') || !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'expired_date') || !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'option_group_id') || !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'end_date') || !CRM_Core_DAO::checkFieldExists('civicrm_group_contact_cache', 'contact_id') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'path_arguments') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'is_exposed') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'page_type')) {
// db looks to have stuck somewhere between 2.0 & 2.1
$errorMessage .= ' Few important fields were found missing in some of the tables.';
return false;
}
$errorMessage = ts('Post-condition failed for upgrade step %1.', array(1 => '1'));
return $this->checkVersion('2.03');
}
示例13: verifyPostDBState
function verifyPostDBState(&$errorMessage)
{
// check if Option Group & Option Values tables exists
if (!CRM_Core_DAO::checkTableExists('civicrm_option_group') || !CRM_Core_DAO::checkTableExists('civicrm_option_value')) {
$errorMessage .= ' option group or option value table is missing.';
return FALSE;
}
// check fields which MUST be present civicrm_option_group & civicrm_option_value
if (!CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'name') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'label') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'description') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'is_reserved') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'is_active')) {
$errorMessage .= ' Few important fields were found missing in civicrm_option_group table.';
return FALSE;
}
if (!CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'option_group_id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'name') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'label') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'description') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'component_id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'is_active')) {
$errorMessage .= ' Few important fields were found missing in civicrm_option_value table.';
return FALSE;
}
$errorMessage = ts('Post-condition failed for upgrade step %1.', array(1 => '1'));
return $this->checkVersion('2.02');
}
示例14: verifyPreDBState
function verifyPreDBState(&$errorMessage)
{
$errorMessage = ts('Pre-condition failed for upgrade step %1.', array(1 => '2'));
if (!CRM_Core_DAO::checkTableExists('civicrm_cache') || !CRM_Core_DAO::checkTableExists('civicrm_group_contact_cache') || !CRM_Core_DAO::checkTableExists('civicrm_menu') || !CRM_Core_DAO::checkTableExists('civicrm_discount') || !CRM_Core_DAO::checkTableExists('civicrm_pledge') || !CRM_Core_DAO::checkTableExists('civicrm_pledge_block') || !CRM_Core_DAO::checkTableExists('civicrm_pledge_payment')) {
return false;
}
// check fields which MUST be present if a proper 2.1 db
if (!CRM_Core_DAO::checkFieldExists('civicrm_cache', 'group_name') || !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'created_date') || !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'expired_date') || !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'option_group_id') || !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'end_date') || !CRM_Core_DAO::checkFieldExists('civicrm_group_contact_cache', 'contact_id') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'path_arguments') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'is_exposed') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'page_type') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'component_id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'name')) {
// db looks to have stuck somewhere between 2.0 & 2.1
$errorMessage .= ' Few important fields were found missing in some of the tables.';
return false;
}
if ($this->checkVersion('2.03')) {
$this->setVersion($this->latestVersion);
} else {
return false;
}
return $this->checkVersion($this->latestVersion);
}
示例15: upgrade_1002
/**
* Method for upgrade 1002
* (rename events to trigger, check https://github.com/CiviCooP/org.civicoop.civirules/issues/42)
* - rename table civirule_event to civirule_trigger
* - rename columns event_id, event_params in table civirule_rule to trigger_id, trigger_params
* - remove index on event_id
* - add index on trigger_id
*/
public function upgrade_1002()
{
// rename table civirule_event to civirule_trigger
if (CRM_Core_DAO::checkTableExists("civirule_event")) {
CRM_Core_DAO::executeQuery("RENAME TABLE civirule_event TO civirule_trigger");
} else {
$this->executeSqlFile('sql/createCiviruleTrigger.sql');
$this->executeSqlFile('sql/insertCiviruleTrigger.sql');
}
// rename columns event_id and event_params in civirule_rule
if (CRM_Core_DAO::checkTableExists("civirule_rule")) {
CRM_Core_DAO::executeQuery("ALTER TABLE civirule_rule DROP FOREIGN KEY fk_rule_event;");
CRM_Core_DAO::executeQuery("ALTER TABLE civirule_rule DROP INDEX fk_rule_event_idx;");
CRM_Core_DAO::executeQuery("ALTER TABLE civirule_rule CHANGE event_id trigger_id INT UNSIGNED;");
CRM_Core_DAO::executeQuery("ALTER TABLE civirule_rule CHANGE event_params trigger_params TEXT;");
CRM_Core_DAO::executeQuery("ALTER TABLE civirule_rule ADD CONSTRAINT fk_rule_trigger FOREIGN KEY (trigger_id) REFERENCES civirule_trigger(id);");
CRM_Core_DAO::executeQuery("ALTER TABLE civirule_rule ADD INDEX fk_rule_trigger_idx (trigger_id);");
}
return true;
}