MODEL_APP::mdl_alert_table PHP Method

mdl_alert_table() public method

修改表 mdl_alert_table function.
public mdl_alert_table ( ) : void
return void
    function mdl_alert_table()
    {
        foreach ($this->appStatus as $_key => $_value) {
            $_arr_status[] = $_key;
        }
        $_str_status = implode("','", $_arr_status);
        foreach ($this->appSyncs as $_key => $_value) {
            $_arr_syncs[] = $_key;
        }
        $_str_syncs = implode("','", $_arr_syncs);
        $_arr_col = $this->mdl_column();
        $_arr_alert = array();
        if (in_array("app_id", $_arr_col)) {
            $_arr_alert["app_id"] = array("CHANGE", "smallint NOT NULL AUTO_INCREMENT COMMENT 'ID'", "app_id");
        }
        if (in_array("app_status", $_arr_col)) {
            $_arr_alert["app_status"] = array("CHANGE", "enum('" . $_str_status . "') NOT NULL COMMENT '状态'", "app_status");
        }
        if (in_array("app_sync", $_arr_col)) {
            $_arr_alert["app_sync"] = array("CHANGE", "enum('" . $_str_syncs . "') NOT NULL COMMENT '状态'", "app_sync");
        }
        if (in_array("app_key", $_arr_col)) {
            $_arr_alert["app_key"] = array("CHANGE", "char(64) NOT NULL COMMENT '校验码'", "app_key");
        }
        if (in_array("app_notice", $_arr_col)) {
            $_arr_alert["app_notice"] = array("CHANGE", "varchar(3000) NOT NULL COMMENT '通知接口 URL'", "app_url_notify");
        } else {
            if (in_array("app_url_notice", $_arr_col)) {
                $_arr_alert["app_url_notice"] = array("CHANGE", "varchar(3000) NOT NULL COMMENT '通知接口 URL'", "app_url_notify");
            } else {
                $_arr_alert["app_url_notify"] = array("ADD", "varchar(3000) NOT NULL COMMENT '通知接口 URL'");
            }
        }
        if (!in_array("app_url_sync", $_arr_col)) {
            $_arr_alert["app_url_sync"] = array("ADD", "varchar(3000) NOT NULL COMMENT '同步接口 URL'", "app_url_sync");
        }
        $_arr_appData = array("app_url_sync" => "app_url_notify");
        $this->obj_db->update(BG_DB_TABLE . "app", $_arr_appData, "LENGTH(app_url_sync) < 1", true);
        //更新数据
        $_str_alert = "y050111";
        if ($_arr_alert) {
            $_reselt = $this->obj_db->alert_table(BG_DB_TABLE . "app", $_arr_alert);
            if ($_reselt) {
                $_str_alert = "y050106";
                $_arr_appData = array("app_status" => $_arr_status[0]);
                $this->obj_db->update(BG_DB_TABLE . "app", $_arr_appData, "LENGTH(app_status) < 1");
                //更新数据
                $_arr_appData = array("app_sync" => $_arr_syncs[0]);
                $this->obj_db->update(BG_DB_TABLE . "app", $_arr_appData, "LENGTH(app_sync) < 1");
                //更新数据
            }
        }
        return array("alert" => $_str_alert);
    }

Usage Example

Beispiel #1
0
 private function table_app()
 {
     include_once BG_PATH_MODEL . "app.class.php";
     //载入管理帐号模型
     $_mdl_app = new MODEL_APP();
     $_arr_appTable = $_mdl_app->mdl_alert_table();
     $this->tplData["db_alert"]["app_table"] = array("alert" => $_arr_appTable["alert"], "status" => substr($_arr_appTable["alert"], 0, 1));
 }