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


PHP SqlHelper::GetUpdates方法代码示例

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


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

示例1: EditEntity

 public function EditEntity($bo)
 {
     $db = new Database();
     $newID = UUID::newID();
     $ID = str_replace("sys", "", $bo["EntityName"]) . "id";
     if ($bo[$ID] != null) {
         $values = SqlHelper::GetUpdates(explode(",", $bo["EntityFields"]), $bo);
         $sql = 'UPDATE ' . $bo["EntityName"] . ' SET ' . $values . ' WHERE ' . $ID . ' = "' . $bo[$ID] . '"';
     } else {
         //
         $fields = str_replace($ID . ",", "", $bo["EntityFields"]);
         $values = SqlHelper::GetValues(explode(",", $fields), $bo);
         $sql = 'INSERT INTO ' . $bo["EntityName"] . '(' . $ID . ',' . $fields . ')' . ' VALUES("' . $newID . '",' . $values . ')';
         //table
         if ($bo["EntityName"] == 'sysentity') {
             $table = ';CREATE TABLE IF NOT EXISTS ' . $bo["Name"] . '(' . $bo["Name"] . 'ID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (' . $bo["Name"] . 'ID))ENGINE = InnoDB';
             $sql .= $table;
         }
         if ($bo["EntityName"] == 'sysproperty') {
             $result = $db->RunSQL('SELECT Name FROM SysEntity WHERE EntityID = ' . $bo["EntityID"]);
             $table = ';ALTER TABLE ' . $result[0]['Name'] . ' ADD COLUMN ' . $bo["Name"] . ' VARCHAR(45) NULL ';
             $sql .= $table;
         }
     }
     $result = $db->ExecuteSQL($sql);
     return $this->GetEntityView($bo["RefreshEntityViewID"], array("id" => $newID));
 }
开发者ID:sasadjolic,项目名称:SailOn,代码行数:27,代码来源:BusinessEntity.php

示例2: EditEntity

 public function EditEntity($bo)
 {
     $db = new Database();
     $newID = UUID::newID();
     $propertyID = UUID::newID();
     $ID = str_replace("sys", "", $bo["entityname"]) . "id";
     $ID_Field = str_replace("sys", "", $bo["name"]) . "id";
     //$sql = "START TRANSACTION;";
     if ($bo[$ID] != null) {
         $values = SqlHelper::GetUpdates(explode(",", $bo["EntityFields"]), $bo);
         $sql .= 'UPDATE ' . $bo["entityname"] . ' SET ' . $values . ' WHERE ' . $ID . ' = "' . $bo[$ID] . '"';
         //echo $sql;
     } else {
         //
         $fields = str_replace("," . $ID . ",", ",", "," . $bo["EntityFields"] . ",");
         $fields = substr($fields, 1, $fields . length - 1);
         $values = SqlHelper::GetValues(explode(",", $fields), $bo);
         $sql .= 'INSERT INTO ' . $bo["entityname"] . '(' . $ID . ',' . $fields . ') VALUES("' . $newID . '",' . $values . ')';
         //echo $sql;
         //table
         if ($bo["entityname"] == 'sysentity') {
             $sql .= ';INSERT INTO sysproperty(propertyid, entityid, name) VALUES("' . $propertyID . '","' . $newID . '", "' . $ID_Field . '")';
             $table = ';CREATE TABLE IF NOT EXISTS ' . $bo["name"] . '(' . $ID_Field . ' VARCHAR(100) NOT NULL, ' . ' createddate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ' . 'PRIMARY KEY (' . $ID_Field . '))ENGINE = InnoDB';
             $sql .= $table;
             //echo $sql;
         }
         if ($bo["entityname"] == 'sysproperty' && !$bo["isonlyview"]) {
             $columnType = ' VARCHAR(255) NULL';
             if ($bo["xtype"] == "numberfield") {
                 $columnType = ' INT NULL';
             } else {
                 if ($bo["xtype"] == "datefield") {
                     $columnType = ' DATETIME NULL';
                 } else {
                     if ($bo["xtype"] == "textareafield") {
                         $columnType = ' TEXT NULL';
                     } else {
                         if ($bo["xtype"] == "checkboxfield") {
                             $columnType = ' BOOL NULL';
                         } else {
                             if ($bo["xtype"] == "htmleditor") {
                                 $columnType = ' TEXT NULL';
                             }
                         }
                     }
                 }
             }
             $result = $db->RunSQL('SELECT name FROM sysentity WHERE entityid = "' . $bo["entityid"] . '"');
             $table = ';ALTER TABLE ' . $result[0]['name'] . ' ADD COLUMN ' . $bo["name"] . ' ' . $columnType;
             $sql .= $table;
         }
     }
     //$sql .= ';COMMIT;';
     //echo $sql;
     $entity = array("entityViewID" => $bo["RefreshEntityViewID"]);
     $result = $db->ExecuteSQL($sql);
     return $this->GetEntityView($entity);
 }
开发者ID:sasadjolic,项目名称:SailOn,代码行数:58,代码来源:BusinessEntity.php


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