本文整理汇总了PHP中ModelCriteria::getModelName方法的典型用法代码示例。如果您正苦于以下问题:PHP ModelCriteria::getModelName方法的具体用法?PHP ModelCriteria::getModelName怎么用?PHP ModelCriteria::getModelName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelCriteria
的用法示例。
在下文中一共展示了ModelCriteria::getModelName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param \ModelCriteria|string $modelOrQuery A query object, or model class as string.
* @param array $options
*/
public function __construct($modelOrQuery, array $options = array())
{
if (is_string($modelOrQuery)) {
$this->model = $modelOrQuery;
$this->query = \PropelQuery::from($this->model);
} else {
if ($modelOrQuery instanceof \ModelCriteria) {
$this->query = $modelOrQuery;
$this->model = $this->query->getModelName();
} else {
throw new \Exception('Invalid argument');
}
}
parent::__construct($options);
}
示例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: filterByKeyword
protected function filterByKeyword(\ModelCriteria $query, $params)
{
if (!empty($params['q'])) {
$columns = array();
$peerClass = constant($this->query->getModelName() . '::PEER');
$phpNames = call_user_func(array($peerClass, 'getFieldNames'));
foreach ($this->columns as $name => $column) {
if (!empty($column['phpName'])) {
if (in_array($column['phpName'], $phpNames)) {
$columns[] = $this->query->getModelName() . '.' . $column['phpName'];
}
}
}
array_unshift($columns, '"|"');
$query->where('CONCAT_WS(' . join(',', $columns) . ') LIKE ?', '%' . $params['q'] . '%');
}
}
示例4: testGetModelName
public function testGetModelName()
{
$c = new ModelCriteria('bookstore', 'Book');
$this->assertEquals('Book', $c->getModelName(), 'getModelName() returns the name of the class associated to the model class');
}