当前位置: 首页>>代码示例>>PHP>>正文


PHP wpdb::hide_errors方法代码示例

本文整理汇总了PHP中wpdb::hide_errors方法的典型用法代码示例。如果您正苦于以下问题:PHP wpdb::hide_errors方法的具体用法?PHP wpdb::hide_errors怎么用?PHP wpdb::hide_errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wpdb的用法示例。


在下文中一共展示了wpdb::hide_errors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upgrade

 /**
  * Upgrade routine
  * - Creates log table on plugin activation
  * - Migrates table structure on updates
  */
 public function upgrade()
 {
     $log_db_version = get_option(self::OPTION_DB_VERSION, 0);
     // only run upgrade routine when database version is lower than code version
     if (version_compare(self::DB_VERSION, $log_db_version, '<=')) {
         return;
     }
     global $charset_collate;
     // don't show errors as this would mess with plugin activation
     $this->db->hide_errors();
     // Create table if it does not exist
     $sql = "\n\t\tCREATE TABLE IF NOT EXISTS {$this->table_name} (\n        ID BIGINT(20) NOT NULL AUTO_INCREMENT,\n        email VARCHAR(255) NOT NULL,\n        list_ids VARCHAR(255) NOT NULL,\n        method VARCHAR(255) NOT NULL,\n        type VARCHAR(255) NOT NULL,\n        success TINYINT(1) DEFAULT 1,\n\t\tdata TEXT NULL,\n        related_object_ID BIGINT(20) NULL,\n        url VARCHAR(255) DEFAULT '',\n        datetime timestamp DEFAULT CURRENT_TIMESTAMP,\n        PRIMARY KEY  (ID)\n\t\t) {$charset_collate}";
     $this->db->query($sql);
     // update to v1.0.4
     if (version_compare($log_db_version, '1.0.4', '<=')) {
         // change 'sign-up_form' in 'sign-up-form';
         $this->db->query("UPDATE `{$this->table_name}` SET `signup_type` = 'sign-up-form' WHERE `signup_type` = 'sign-up_form'");
     }
     // update to v1.1
     if (version_compare($log_db_version, '1.1', '<=')) {
         // merge columns `form_ID` and `comment_ID` into `related_object_ID`
         $this->db->query("ALTER TABLE `{$this->table_name}` CHANGE COLUMN `form_ID` `related_object_ID` BIGINT(20)");
         $this->db->query("UPDATE `{$this->table_name}` SET `related_object_ID` = `comment_ID` WHERE `related_object_ID` = 0 AND `comment_ID` > 0 ");
         $this->db->query("ALTER TABLE `{$this->table_name}` DROP COLUMN `comment_ID`");
         // add 'success' column
         $this->db->query("ALTER TABLE `{$this->table_name}` ADD COLUMN `success` TINYINT(1) DEFAULT 1");
         // rename columns
         $this->db->query("ALTER TABLE `{$this->table_name}` CHANGE COLUMN `signup_method` `method` VARCHAR(255)");
         $this->db->query("ALTER TABLE `{$this->table_name}` CHANGE COLUMN `signup_type` `type` VARCHAR(255)");
         $this->db->query("ALTER TABLE `{$this->table_name}` CHANGE COLUMN `merge_vars` `data` TEXT");
         // alter datatype of `datetime`
         $this->db->query("ALTER TABLE `{$this->table_name}` CHANGE COLUMN `datetime` `datetime` timestamp DEFAULT CURRENT_TIMESTAMP");
         // change `sign-up-form` to just `form`
         $this->db->query("UPDATE `{$this->table_name}` SET `type` = 'form' WHERE `type` = 'sign-up-form'");
     }
     $this->db->show_errors();
     update_option(self::OPTION_DB_VERSION, self::DB_VERSION);
 }
开发者ID:NClaus,项目名称:Ambrose,代码行数:43,代码来源:class-logger.php


注:本文中的wpdb::hide_errors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。