本文整理汇总了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)) {
//.........这里部分代码省略.........