當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。