mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-23 18:18:21 +08:00
Merge branch 'klimov-paul-mongodb-debug-short'
This commit is contained in:
@@ -47,6 +47,14 @@ class DbPanel extends Panel
|
|||||||
return 'Database';
|
return 'Database';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string short name of the panel, which will be use in summary.
|
||||||
|
*/
|
||||||
|
public function getSummaryName()
|
||||||
|
{
|
||||||
|
return 'DB';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use yii\helpers\Html;
|
|||||||
use yii\grid\GridView;
|
use yii\grid\GridView;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<h1>Database Queries</h1>
|
<h1><?= $panel->getName(); ?> Queries</h1>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<?php if ($queryCount): ?>
|
<?php if ($queryCount): ?>
|
||||||
<div class="yii-debug-toolbar-block">
|
<div class="yii-debug-toolbar-block">
|
||||||
<a href="<?= $panel->getUrl() ?>" title="Executed <?= $queryCount ?> database queries which took <?= $queryTime ?>.">
|
<a href="<?= $panel->getUrl() ?>" title="Executed <?= $queryCount ?> database queries which took <?= $queryTime ?>.">
|
||||||
DB <span class="label label-info"><?= $queryCount ?></span> <span class="label"><?= $queryTime ?></span>
|
<?= $panel->getSummaryName() ?> <span class="label label-info"><?= $queryCount ?></span> <span class="label"><?= $queryTime ?></span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ Yii Framework 2 mongodb extension Change Log
|
|||||||
- Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
|
- Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
|
||||||
- Enh #3778: Gii generator for Active Record model added (klimov-paul)
|
- Enh #3778: Gii generator for Active Record model added (klimov-paul)
|
||||||
- Enh #3947: Migration support added (klimov-paul)
|
- Enh #3947: Migration support added (klimov-paul)
|
||||||
|
- Enh #3855: Enh: Added a debug toolbar panel for MongoDB (klimov-paul)
|
||||||
- Enh #4048: Added `init` event to `ActiveQuery` classes (qiangxue)
|
- Enh #4048: Added `init` event to `ActiveQuery` classes (qiangxue)
|
||||||
- Enh #4086: changedAttributes of afterSave Event now contain old values (dizews)
|
- Enh #4086: changedAttributes of afterSave Event now contain old values (dizews)
|
||||||
- Enh #4335: `yii\mongodb\log\MongoDbTarget` log target added (klimov-paul)
|
- Enh #4335: `yii\mongodb\log\MongoDbTarget` log target added (klimov-paul)
|
||||||
|
|||||||
@@ -288,6 +288,32 @@ return [
|
|||||||
is very basic and definitely requires adjustments.
|
is very basic and definitely requires adjustments.
|
||||||
|
|
||||||
|
|
||||||
|
Using the MongoDB DebugPanel
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
The yii2 MongoDB extensions provides a debug panel that can be integrated with the yii debug module
|
||||||
|
and shows the executed MongoDB queries.
|
||||||
|
|
||||||
|
Add the following to you application config to enable it (if you already have the debug module
|
||||||
|
enabled, it is sufficient to just add the panels configuration):
|
||||||
|
|
||||||
|
```php
|
||||||
|
// ...
|
||||||
|
'bootstrap' => ['debug'],
|
||||||
|
'modules' => [
|
||||||
|
'debug' => [
|
||||||
|
'class' => 'yii\\debug\\Module',
|
||||||
|
'panels' => [
|
||||||
|
'mongodb' => [
|
||||||
|
'class' => 'yii\\mongodb\\debug\\MongoDbPanel',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
// ...
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Using Migrations
|
Using Migrations
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
|||||||
51
extensions/mongodb/debug/MongoDbPanel.php
Normal file
51
extensions/mongodb/debug/MongoDbPanel.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @link http://www.yiiframework.com/
|
||||||
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||||
|
* @license http://www.yiiframework.com/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace yii\mongodb\debug;
|
||||||
|
|
||||||
|
use yii\debug\panels\DbPanel;
|
||||||
|
use yii\log\Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MongoDbPanel panel that collects and displays MongoDB queries performed.
|
||||||
|
*
|
||||||
|
* @author Klimov Paul <klimov@zfort.com>
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
class MongoDbPanel extends DbPanel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'MongoDB';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function getSummaryName()
|
||||||
|
{
|
||||||
|
return 'MongoDB';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all profile logs of the current request for this panel.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getProfileLogs()
|
||||||
|
{
|
||||||
|
$target = $this->module->logTarget;
|
||||||
|
|
||||||
|
return $target->filterMessages($target->messages, Logger::LEVEL_PROFILE, [
|
||||||
|
'yii\mongodb\Collection::*',
|
||||||
|
'yii\mongodb\Query::*',
|
||||||
|
'yii\mongodb\Database::*',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user