本文整理汇总了PHP中ModelCriteria::getAsColumns方法的典型用法代码示例。如果您正苦于以下问题:PHP ModelCriteria::getAsColumns方法的具体用法?PHP ModelCriteria::getAsColumns怎么用?PHP ModelCriteria::getAsColumns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelCriteria
的用法示例。
在下文中一共展示了ModelCriteria::getAsColumns方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addQueryColumns
protected function addQueryColumns()
{
$tableMap = $this->query->getTableMap();
foreach ($tableMap->getColumns() as $column) {
if ($column->isForeignKey()) {
continue;
}
$name = strtolower($column->getName());
$this->addColumn($name, array('hide' => $column->isPrimaryKey(), 'phpName' => $column->getPhpName(), 'action' => $column->isPrimaryString() ? 'edit' : null));
}
// add virtual columns
foreach ($this->query->getAsColumns() as $colName => $clause) {
$this->addColumn($colName, array('phpName' => $colName));
}
$behaviors = $tableMap->getBehaviors();
if (array_key_exists('sortable', $behaviors)) {
$rankCol = strtolower($behaviors['sortable']['rank_column']);
if (isset($this->columns[$rankCol])) {
$this->addColumn($rankCol, array('hide' => true));
$this->setOptions(array('defaultSortColumn' => $rankCol));
}
$this->setOptions(array('sortable' => array($this, 'sortItems')));
}
$i18nTableName = $this->getI18nTableName($tableMap);
if ($i18nTableName !== null && $this->query->getJoin($i18nTableName) !== null) {
$i18nTableMap = \PropelQuery::from($i18nTableName)->getTableMap();
foreach ($i18nTableMap->getColumns() as $column) {
if ($column->isPrimaryKey()) {
continue;
}
$this->addColumn(strtolower($column->getName()), array('sortCallback' => array($this, 'sortI18nColumn'), 'phpName' => $column->getPhpName()));
}
}
}
示例2: init
/**
* Define the hydration schema based on a query object.
* Fills the Formatter's properties using a Criteria as source
*
* @param ModelCriteria $criteria
*
* @return PropelFormatter The current formatter object
*/
public function init(ModelCriteria $criteria)
{
$this->dbName = $criteria->getDbName();
$this->setClass($criteria->getModelName());
$this->setWith($criteria->getWith());
$this->asColumns = $criteria->getAsColumns();
$this->hasLimit = $criteria->getLimit() != 0;
return $this;
}
示例3: getRow
/**
* Get row properties.
*
* @param BaseObject $obj
* @return array
*/
protected function getRow($obj)
{
$columnToPhpName = array();
foreach ($this->tableMap->getColumns() as $name => $column) {
$columnToPhpName[strtolower($name)] = $column->getPhpName();
}
$celldata = array();
foreach ($this->columns as $column => $opts) {
if (isset($this->callbacks[$column])) {
$value = call_user_func($this->callbacks[$column], $obj);
} else {
try {
if (isset($columnToPhpName[$column])) {
$phpName = $columnToPhpName[$column];
} else {
$tmp = $this->query->getAsColumns();
if (isset($tmp[$column])) {
$phpName = $column;
}
}
$value = $obj->{'get' . $phpName}();
} catch (Exception $e) {
throw new Exception("Unable to fetch value from column '{$column}'.");
}
}
if (is_null($value)) {
$value = 'Ø';
} else {
if (is_bool($value)) {
$value = $value ? 'true' : 'false';
} else {
if (is_array($value)) {
$value = join(', ', $value);
}
}
}
$escape = !isset($opts['escape']) ? true : (bool) $opts['escape'];
$value = str_replace(PHP_EOL, "", $value);
$celldata[] = $escape ? htmlspecialchars($value) : $value;
}
return array("id" => "_" . $obj->getPrimaryKey(), "cell" => $celldata);
}