Class yii\debug\models\search\Db
| Inheritance | yii\ |
|---|---|
| Available since extension's version | 2.0 |
| Source Code | https://github.com/yiisoft/yii2-debug/blob/master/src/models/search/Db.php |
Search model for current request database queries.
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $query | integer | Query attribute input search value | yii\ |
| $type | string | Type of the input search value | yii\ |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| addCondition() | Adds filtering condition for a given attribute | yii\ |
| attributeLabels() | yii\ |
|
| rules() | yii\ |
|
| search() | Returns data provider with filled models. Filter applied if needed. | yii\ |
Property Details
Method Details
Defined in:
yii\
Adds filtering condition for a given attribute
| public mixed addCondition ( yii\ | ||
| $filter | yii\ |
Filter instance |
| $attribute | string |
Attribute to filter |
| $partial | boolean |
If partial match should be used |
public function addCondition(Filter $filter, $attribute, $partial = false)
{
$value = (string)$this->$attribute;
if (mb_strpos($value, '>') !== false) {
$value = (int)str_replace('>', '', $value);
$filter->addMatcher($attribute, new matchers\GreaterThan(['value' => $value]));
} elseif (mb_strpos($value, '<') !== false) {
$value = (int)str_replace('<', '', $value);
$filter->addMatcher($attribute, new matchers\LowerThan(['value' => $value]));
} else {
$filter->addMatcher($attribute, new matchers\SameAs(['value' => $value, 'partial' => $partial]));
}
}
| public attributeLabels ( ) |
public function attributeLabels()
{
return [
'type' => 'Type',
'query' => 'Query',
];
}
Returns data provider with filled models. Filter applied if needed.
| public \ | ||
| $models | array |
Data to return provider for |
public function search($models)
{
$dataProvider = new ArrayDataProvider([
'allModels' => $models,
'pagination' => false,
'sort' => [
'attributes' => ['duration', 'seq', 'type', 'query', 'duplicate'],
],
]);
if (!$this->validate()) {
return $dataProvider;
}
$filter = new Filter();
$this->addCondition($filter, 'type', true);
$this->addCondition($filter, 'query', true);
$dataProvider->allModels = $filter->filter($models);
return $dataProvider;
}