Skip to content

Commit

Permalink
fixed warnings for array key lookups on explain
Browse files Browse the repository at this point in the history
  • Loading branch information
gtowey committed Apr 10, 2014
1 parent 8fe0536 commit 1b36e74
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions lib/QueryExplain.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function result_as_table($result) {
while ($row = $result->fetch_assoc()) {
foreach ($row as $col_name => $value) {
$len = strlen($value);
if ($len > $sizes[$col_name]) {
if (array_key_exists($col_name, $sizes) and $len > $sizes[$col_name]) {
$sizes[$col_name] = $len;
}

Expand All @@ -237,10 +237,17 @@ function result_as_table($result) {
}

foreach ($columns as $col => $count) {
$len = strlen($col);
if ($len > $sizes[$col]) {
$sizes[$col] = $len;
$len = strlen($col) + 0;
if (array_key_exists($col, $sizes))
{
if ( $len > $sizes[$col]) {
$sizes[$col] = $len;
}
}
else
{
$sizes[$col] = $len;
}
}

$column_order = array_keys($columns);
Expand Down
4 changes: 2 additions & 2 deletions lib/QueryTableParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function parse($query) {

if (preg_match("/\w+/", $table)) {
$table = str_replace('`', '', $table);
$tables[$table]++;
$tables[$table]=1;
}
}
}
Expand Down Expand Up @@ -98,4 +98,4 @@ private function get_next_token() {

}

?>
?>

0 comments on commit 1b36e74

Please sign in to comment.