| Total Complexity | 12 |
| Total Lines | 87 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class QueryProfile extends Profile |
||
| 12 | { |
||
| 13 | public $query; |
||
| 14 | public $type; |
||
| 15 | public $adapter; |
||
| 16 | |||
| 17 | public $info; |
||
| 18 | public $affectedRows; |
||
| 19 | public $columns = ['time', 'type', 'memory', 'query', 'affectedRows', 'info']; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param null $name |
||
|
|
|||
| 23 | */ |
||
| 24 | public function setName($name) |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @return string |
||
| 34 | */ |
||
| 35 | public function detectQueryType() |
||
| 36 | { |
||
| 37 | // make sure we have a query type |
||
| 38 | switch (strtolower(substr($this->query, 0, 6))) { |
||
| 39 | case 'insert': |
||
| 40 | return 'INSERT'; |
||
| 41 | |||
| 42 | case 'update': |
||
| 43 | return 'UPDATE'; |
||
| 44 | |||
| 45 | case 'delete': |
||
| 46 | return 'DELETE'; |
||
| 47 | |||
| 48 | case 'select': |
||
| 49 | return 'SELECT'; |
||
| 50 | |||
| 51 | default: |
||
| 52 | return 'QUERY'; |
||
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return mixed |
||
| 58 | */ |
||
| 59 | public function getQuery() |
||
| 60 | { |
||
| 61 | return $this->query; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return mixed |
||
| 66 | */ |
||
| 67 | public function getConnection() |
||
| 70 | } |
||
| 71 | |||
| 72 | public function calculateResources() |
||
| 73 | { |
||
| 74 | parent::calculateResources(); |
||
| 75 | $this->getInfo(); |
||
| 76 | } |
||
| 77 | |||
| 78 | public function getInfo() |
||
| 79 | { |
||
| 80 | $this->info = $this->getAdapter()->info(); |
||
| 81 | $this->affectedRows = $this->getAdapter()->affectedRows(); |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @return mixed |
||
| 86 | */ |
||
| 87 | public function getAdapter() |
||
| 88 | { |
||
| 89 | return $this->adapter; |
||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @param mixed $adapter |
||
| 94 | */ |
||
| 95 | public function setAdapter($adapter) |
||
| 98 | } |
||
| 99 | } |
||
| 100 |