本文整理汇总了PHP中JDatabaseQuery::__toString方法的典型用法代码示例。如果您正苦于以下问题:PHP JDatabaseQuery::__toString方法的具体用法?PHP JDatabaseQuery::__toString怎么用?PHP JDatabaseQuery::__toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDatabaseQuery
的用法示例。
在下文中一共展示了JDatabaseQuery::__toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __toString
/**
* Magic function to convert the query to a string.
*
* @return string The completed query.
*
* @since 11.1
*/
public function __toString()
{
$query = '';
switch ($this->type) {
case 'insert':
$query .= (string) $this->insert;
// Set method
if ($this->set) {
$query .= (string) $this->set;
} elseif ($this->values) {
if ($this->columns) {
$query .= (string) $this->columns;
}
$elements = $this->insert->getElements();
$tableName = array_shift($elements);
$query .= 'VALUES ';
$query .= (string) $this->values;
if ($this->autoIncrementField) {
$query = 'SET IDENTITY_INSERT ' . $tableName . ' ON;' . $query . 'SET IDENTITY_INSERT ' . $tableName . ' OFF;';
}
if ($this->where) {
$query .= (string) $this->where;
}
}
break;
default:
$query = parent::__toString();
break;
}
return $query;
}
示例2: __toString
/**
* Magic function to convert the query to a string.
*
* @return string The completed query.
*
* @since 11.1
*/
public function __toString()
{
$query = '';
switch ($this->type) {
case 'select':
$query .= (string) $this->select;
$query .= (string) $this->from;
// Get the limit and offset values from JDatabase
$limit = $this->db->getLimit();
$offset = $this->db->getOffset();
if ($limit > 0 || $offset > 0) {
if ($this->order) {
$query .= (string) $this->order;
}
$query = $this->processLimit($query, $limit, $offset);
}
if ($this->join) {
// special case for joins
foreach ($this->join as $join) {
$query .= (string) $join;
}
}
if ($this->where) {
$query .= (string) $this->where;
}
if ($this->group) {
$query .= (string) $this->group;
}
if ($this->having) {
$query .= (string) $this->having;
}
break;
case 'insert':
$query .= (string) $this->insert;
// Set method
if ($this->set) {
$query .= (string) $this->set;
} elseif ($this->values) {
if ($this->columns) {
$query .= (string) $this->columns;
}
$elements = $this->insert->getElements();
$tableName = array_shift($elements);
$query .= 'VALUES ';
$query .= (string) $this->values;
if ($this->autoIncrementField) {
$query = 'SET IDENTITY_INSERT ' . $tableName . ' ON;' . $query . 'SET IDENTITY_INSERT ' . $tableName . ' OFF;';
}
if ($this->where) {
$query .= (string) $this->where;
}
}
break;
default:
$query = parent::__toString();
break;
}
return $query;
}
示例3: __toString
/**
* Magic function to convert the query to a string, only for postgresql specific query
*
* @return string The completed query.
*
* @since 11.3
*/
public function __toString()
{
$query = '';
switch ($this->type) {
case 'select':
$query .= (string) $this->select;
$query .= (string) $this->from;
if ($this->join) {
// Special case for joins
foreach ($this->join as $join) {
$query .= (string) $join;
}
}
if ($this->where) {
$query .= (string) $this->where;
}
if ($this->group) {
$query .= (string) $this->group;
}
if ($this->having) {
$query .= (string) $this->having;
}
if ($this->order) {
$query .= (string) $this->order;
}
if ($this->limit) {
$query .= (string) $this->limit;
}
if ($this->offset) {
$query .= (string) $this->offset;
}
if ($this->forUpdate) {
$query .= (string) $this->forUpdate;
} else {
if ($this->forShare) {
$query .= (string) $this->forShare;
}
}
if ($this->noWait) {
$query .= (string) $this->noWait;
}
break;
case 'update':
$query .= (string) $this->update;
$query .= (string) $this->set;
if ($this->join) {
$onWord = ' ON ';
// Workaround for special case of JOIN with UPDATE
foreach ($this->join as $join) {
$joinElem = $join->getElements();
$joinArray = explode($onWord, $joinElem[0]);
$this->from($joinArray[0]);
$this->where($joinArray[1]);
}
$query .= (string) $this->from;
}
if ($this->where) {
$query .= (string) $this->where;
}
break;
case 'insert':
$query .= (string) $this->insert;
if ($this->values) {
if ($this->columns) {
$query .= (string) $this->columns;
}
$elements = $this->values->getElements();
if (!$elements[0] instanceof $this) {
$query .= ' VALUES ';
}
$query .= (string) $this->values;
if ($this->returning) {
$query .= (string) $this->returning;
}
}
break;
default:
$query = parent::__toString();
break;
}
return $query;
}