PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/demos/Zend/Wildfire/public/Boot/Zend-Db-Profiler-Firebug/TestDocExample.php

https://github.com/decaoz/zf1
PHP | 51 lines | 37 code | 14 blank | 0 comment | 0 complexity | 0712ef22f15436100c1a053b847343f3 MD5 | raw file
 1<?php
 2
 3require_once('Zend/Loader/Autoloader.php');
 4Zend_Loader_Autoloader::getInstance();
 5
 6switch($_GET['Example']) {
 7
 8    case 'WithController':
 9
10        $profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
11        $profiler->setEnabled(true);
12        $db = Zend_Db::factory('PDO_SQLITE', array('dbname' => ':memory:'));
13        $db->setProfiler($profiler);
14        Zend_Registry::set('db',$db);
15
16        $controller = Zend_Controller_Front::getInstance();
17        $controller->setParam('useDefaultControllerAlways',true);
18        $controller->setParam('noViewRenderer', true);
19        $controller->setControllerDirectory(dirname(dirname(dirname(dirname(__FILE__)))).'/application/controllers/Boot/Zend-Db-Profiler-Firebug');
20        $controller->dispatch();
21
22        print 'Test Doc Example with Controller';
23        break;
24
25    case 'WithoutController':
26
27        $profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
28        $profiler->setEnabled(true);
29        $db = Zend_Db::factory('PDO_SQLITE', array('dbname' => ':memory:'));
30        $db->setProfiler($profiler);
31
32        $request  = new Zend_Controller_Request_Http();
33        $response = new Zend_Controller_Response_Http();
34        $channel  = Zend_Wildfire_Channel_HttpHeaders::getInstance();
35        $channel->setRequest($request);
36        $channel->setResponse($response);
37
38        $db->getConnection()->exec('CREATE TABLE foo (
39                                      id      INTEGNER NOT NULL,
40                                      col1    VARCHAR(10) NOT NULL
41                                    )');
42
43        $db->insert('foo', array('id'=>1,'col1'=>'original'));
44
45        $channel->flush();
46        $response->sendHeaders();
47
48        print 'Test Doc Example without Controller';
49        break;
50
51}