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


PHP QueryObject::buildUpdate方法代码示例

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


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

示例1: buildQuery

 /**
  * (non-PHPdoc)
  * @see QueryObjectInterface::buildQuery()
  */
 public function buildQuery()
 {
     if (!$this->__sql) {
         $sql = $this->sql;
         if (empty($sql)) {
             if ($this->accept(QueryObject::SELECT)) {
                 /**
                  *
                  * fields
                  *
                  */
                 $fields = $this->fields;
                 if (empty($fields)) {
                     $fields = '*';
                 } else {
                     foreach ($fields as &$field) {
                         if ($field instanceof QueryObjectInterface) {
                             $field = $field->buildQuery();
                         }
                     }
                     $fields = implode(', ', $fields);
                 }
                 $sql = "SELECT {$fields} FROM ";
             } elseif ($this->accept(QueryObject::INSERT)) {
                 $sql = "INSERT INTO ";
             } elseif ($this->accept(QueryObject::UPDATE)) {
                 $sql = "UPDATE ";
             } elseif ($this->accept(QueryObject::DELETE)) {
                 $sql = "DELETE FROM ";
             }
             /**
              *
              * tables
              *
              */
             if (empty($this->table)) {
                 throw new Exception('No table set for query');
             } else {
                 $tables = $this->table;
                 foreach ($tables as &$table) {
                     if ($table instanceof QueryObjectInterface) {
                         $table = $table->buildQuery();
                     }
                 }
                 $table = implode(', ', $tables);
             }
             $sql .= "{$table} ";
             if ($this->accept(QueryObject::UPDATE) && !empty($this->data)) {
                 $sql .= 'SET ' . QueryObject::buildUpdate($this->data) . ' ';
             } elseif ($this->accept(QueryObject::INSERT) && !empty($this->data)) {
                 $sql .= QueryObject::buildInsert($this->data) . ' ';
             }
             if ($this->accept(QueryObject::SELECT)) {
                 /**
                  *
                  * joins
                  *
                  */
                 if (!empty($this->joins)) {
                     $joins = $this->joins;
                     foreach ($joins as &$join) {
                         if ($join[1] instanceof QueryObjectInterface) {
                             $join[1] = $join->buildQuery();
                         }
                         $join = implode(' ', $join);
                     }
                     $sql .= implode(' ', $joins) . ' ';
                 }
             }
             if ($this->accept(QueryObject::ALL ^ QueryObject::INSERT)) {
                 /**
                  *
                  * where
                  *
                  */
                 if (!empty($this->where)) {
                     $where = $this->where;
                     foreach ($where as &$_where) {
                         if ($_where instanceof QueryObjectInterface) {
                             $_where = $_where->buildQuery();
                         }
                     }
                     $where = BoolExpr::parse($where);
                     $sql .= "WHERE {$where} ";
                 }
             }
             if ($this->accept(QueryObject::SELECT)) {
                 /**
                  *
                  * group by and having
                  *
                  */
                 if (!empty($this->groupBy)) {
                     $groupBy = implode(', ', $this->groupBy);
                     $sql .= "GROUP BY {$groupBy} ";
                     if (!empty($this->having)) {
//.........这里部分代码省略.........
开发者ID:rutkoski,项目名称:util,代码行数:101,代码来源:QueryObject.php


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