1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Zend\DbのProfilerを利用する

Last updated at Posted at 2013-03-09

Zend\Dbを単体で使わず、SkeletonApplication使ってる場合は、ZendDeveloperToolsで使われてるBjyProfilerでも使った方がいいと思います。
※ ちなみに、私が使ってるzf2のversionはdevelopです。

<?php
use Zend\Db\Adapter\Adapter;
use Zend\Db\Adapter\Profiler\Profiler;
use Zend\Db\Adapter\StatementContainer;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql\Select;

$config = include 'bootstrap.php';
$adapter = new Adapter($config);


$profiler = new Profiler;
$adapter->setProfiler($profiler);

$table = new TableGateway('news', $adapter);

$profiler->profilerStart(new StatementContainer);

echo $table->select(function(Select $select){$select->where('id', 1);})->current()->id; // 1

$profiler->getLastProfile();
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?