| @@ 153-196 (lines=44) @@ | ||
| 150 | $sql = $sql[0]; |
|
| 151 | } |
|
| 152 | ||
| 153 | if ($this->showQueries && Director::isDev()) { |
|
| 154 | $starttime = microtime(true); |
|
| 155 | $result = $callback($sql); |
|
| 156 | $endtime = round(microtime(true) - $starttime, 4); |
|
| 157 | ||
| 158 | $formattedSql = JdornSqlFormatter::format($sql); |
|
| 159 | $rows = $result->numRecords(); |
|
| 160 | echo '<pre>The following query took <b>'.$endtime.'</b>s an returned <b>'.$rows."</b> row(s) \n"; |
|
| 161 | echo 'Triggered by: <i>'.$this->findSource().'</i></pre>'; |
|
| 162 | echo $formattedSql; |
|
| 163 | ||
| 164 | $results = iterator_to_array($result); |
|
| 165 | if ($rows > 0) { |
|
| 166 | if ($rows == 1) { |
|
| 167 | dump($results[0]); |
|
| 168 | } else { |
|
| 169 | $linearValues = count($results[0]); |
|
| 170 | if ($linearValues) { |
|
| 171 | dump(implode( |
|
| 172 | ',', |
|
| 173 | array_map( |
|
| 174 | function ($item) { |
|
| 175 | return $item[key($item)]; |
|
| 176 | }, |
|
| 177 | $results |
|
| 178 | ) |
|
| 179 | )); |
|
| 180 | } else { |
|
| 181 | if ($rows < 20) { |
|
| 182 | dump($results); |
|
| 183 | } else { |
|
| 184 | dump("Too many results to display"); |
|
| 185 | } |
|
| 186 | } |
|
| 187 | } |
|
| 188 | } |
|
| 189 | echo '<hr/>'; |
|
| 190 | ||
| 191 | $handle = $result; |
|
| 192 | $handle->rewind(); // Rewind the results |
|
| 193 | } else { |
|
| 194 | /* @var $handle PDOQuery */ |
|
| 195 | $handle = $callback($sql); |
|
| 196 | } |
|
| 197 | $endtime = microtime(true); |
|
| 198 | $endmemory = memory_get_usage(true); |
|
| 199 | ||
| @@ 143-180 (lines=38) @@ | ||
| 140 | $starttime = microtime(true); |
|
| 141 | $startmemory = memory_get_usage(true); |
|
| 142 | ||
| 143 | if ($this->showQueries && Director::isDev()) { |
|
| 144 | $starttime = microtime(true); |
|
| 145 | $result = $callback($sql); |
|
| 146 | $endtime = round(microtime(true) - $starttime, 4); |
|
| 147 | ||
| 148 | $formattedSql = JdornSqlFormatter::format($sql); |
|
| 149 | $rows = $result->numRecords(); |
|
| 150 | echo '<pre>The following query took <b>'.$endtime.'</b>s an returned <b>'.$rows."</b> row(s) \n"; |
|
| 151 | echo 'Triggered by: <i>'.$this->findSource().'</i></pre>'; |
|
| 152 | echo $formattedSql; |
|
| 153 | ||
| 154 | $results = iterator_to_array($result); |
|
| 155 | if ($rows > 0) { |
|
| 156 | if ($rows == 1) { |
|
| 157 | dump($results[0]); |
|
| 158 | } else { |
|
| 159 | $linearValues = count($results[0]); |
|
| 160 | if ($linearValues) { |
|
| 161 | dump(implode(',', (array_map(function ($item) { |
|
| 162 | return $item[key($item)]; |
|
| 163 | }, $results)))); |
|
| 164 | } else { |
|
| 165 | if ($rows < 20) { |
|
| 166 | dump($results); |
|
| 167 | } else { |
|
| 168 | dump("Too many results to display"); |
|
| 169 | } |
|
| 170 | } |
|
| 171 | } |
|
| 172 | } |
|
| 173 | echo '<hr/>'; |
|
| 174 | ||
| 175 | $handle = $result; |
|
| 176 | $handle->rewind(); // Rewind the results |
|
| 177 | } else { |
|
| 178 | /* @var $handle MySQLQuery */ |
|
| 179 | $handle = $callback($sql); |
|
| 180 | } |
|
| 181 | ||
| 182 | $endtime = microtime(true); |
|
| 183 | $endmemory = memory_get_usage(true); |
|