ZendDbProfilerFirebugController.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Wildfire
  17. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. */
  20. /** Zend_Controller_Action */
  21. require_once 'Zend/Controller/Action.php';
  22. /**
  23. * Tests for Zend_Db_Profiler_Firebug
  24. *
  25. * @category Zend
  26. * @package Zend_Wildfire
  27. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. */
  30. class ZendDbProfilerFirebugController extends Zend_Controller_Action
  31. {
  32. public function testloggingAction()
  33. {
  34. $db = Zend_Registry::get('db');
  35. $db->getConnection()->exec('CREATE TABLE foo (
  36. id INTEGNER NOT NULL,
  37. col1 VARCHAR(10) NOT NULL
  38. )');
  39. $db->insert('foo', array('id'=>1,'col1'=>'original'));
  40. $db->fetchAll('SELECT * FROM foo WHERE id = ?', 1);
  41. $db->update('foo', array('col1'=>'new'), 'id = 1');
  42. $db->fetchAll('SELECT * FROM foo WHERE id = ?', 1);
  43. $db->delete('foo', 'id = 1');
  44. $db->getConnection()->exec('DROP TABLE foo');
  45. }
  46. public function testmultipledatabasesAction()
  47. {
  48. $profiler1 = new Zend_Db_Profiler_Firebug('All DB Queries for first database');
  49. $db1 = Zend_Db::factory('PDO_SQLITE',
  50. array('dbname' => ':memory:',
  51. 'profiler' => $profiler1));
  52. $db1->getProfiler()->setEnabled(true);
  53. $profiler2 = new Zend_Db_Profiler_Firebug('All DB Queries for second database');
  54. $db2 = Zend_Db::factory('PDO_SQLITE',
  55. array('dbname' => ':memory:',
  56. 'profiler' => $profiler2));
  57. $db2->getProfiler()->setEnabled(true);
  58. $db1->getConnection()->exec('CREATE TABLE foo (
  59. id INTEGNER NOT NULL,
  60. col1 VARCHAR(10) NOT NULL
  61. )');
  62. $db1->insert('foo', array('id'=>1,'col1'=>'original'));
  63. $db2->getConnection()->exec('CREATE TABLE foo (
  64. id INTEGNER NOT NULL,
  65. col1 VARCHAR(10) NOT NULL
  66. )');
  67. $db2->insert('foo', array('id'=>1,'col1'=>'original'));
  68. }
  69. }