本文整理汇总了PHP中SQLQuery::expressionForField方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLQuery::expressionForField方法的具体用法?PHP SQLQuery::expressionForField怎么用?PHP SQLQuery::expressionForField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLQuery
的用法示例。
在下文中一共展示了SQLQuery::expressionForField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: selectColumnsFromTable
/**
* Update the SELECT clause of the query with the columns from the given table
*/
protected function selectColumnsFromTable(SQLQuery &$query, $tableClass, $columns = null)
{
// Add SQL for multi-value fields
$databaseFields = DataObject::database_fields($tableClass);
$compositeFields = DataObject::composite_fields($tableClass, false);
if ($databaseFields) {
foreach ($databaseFields as $k => $v) {
if ((is_null($columns) || in_array($k, $columns)) && !isset($compositeFields[$k])) {
// Update $collidingFields if necessary
if ($expressionForField = $query->expressionForField($k)) {
if (!isset($this->collidingFields[$k])) {
$this->collidingFields[$k] = array($expressionForField);
}
$this->collidingFields[$k][] = "\"{$tableClass}\".\"{$k}\"";
} else {
$query->selectField("\"{$tableClass}\".\"{$k}\"", $k);
}
}
}
}
if ($compositeFields) {
foreach ($compositeFields as $k => $v) {
if ((is_null($columns) || in_array($k, $columns)) && $v) {
$dbO = Object::create_from_string($v, $k);
$dbO->addToQuery($query);
}
}
}
}
示例2: expressionForField
/**
* @param String $field Select statement identifier, either the unquoted column name,
* the full composite SQL statement, or the alias set through {@link SQLQuery->selectField()}.
* @param SQLQuery $query
* @return String
*/
protected function expressionForField($field, $query)
{
// Special case for ID
if ($field == 'ID') {
$baseClass = ClassInfo::baseDataClass($this->dataClass);
return "\"{$baseClass}\".\"ID\"";
} else {
return $query->expressionForField($field);
}
}