本文整理匯總了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');
}