conn; try { $conn->multiQuery ($_REQUEST['sql']); do { $result = $conn->storeResult (); if ($result !== FALSE) { $columns = $result->fetch_fields (); $resultMap = []; $resultMap['data'] = []; $resultMap['field'] = []; for ($i = 0; $i < $result->field_count; $i++) { $column = $columns[$i]; switch ($column->type) { case MYSQLI_TYPE_BIT: $type = TYPE_BOOLEAN; break; case MYSQLI_TYPE_TINY: case MYSQLI_TYPE_SHORT: case MYSQLI_TYPE_LONG: case MYSQLI_TYPE_LONGLONG: case MYSQLI_TYPE_INT24: case MYSQLI_TYPE_YEAR: $type = TYPE_INTEGER; break; case MYSQLI_TYPE_FLOAT: case MYSQLI_TYPE_DOUBLE: case MYSQLI_TYPE_DECIMAL: case MYSQLI_TYPE_NEWDECIMAL: $type = TYPE_DOUBLE; break; case MYSQLI_TYPE_DATE: $type = TYPE_DATE; break; case MYSQLI_TYPE_DATETIME: case MYSQLI_TYPE_TIMESTAMP: $type = TYPE_DATE_TIME; break; default; $type = TYPE_STRING; } $resultMap['field'][] = [ 'name' => $column->name, 'orgname' => $column->orgname, 'table' => $column->table, 'orgtable' => $column->orgtable, 'def' => $column->def, 'db' => $column->db, 'flags' => $column->flags, 'type' => $type ]; } while ($row = $result->fetch_row ()) { for ($j = 0; $j < $result->field_count; $j++) { $cell = &$row[$j]; if ($cell !== NULL) switch ($columns[$j]->type) { case MYSQLI_TYPE_DATE: case MYSQLI_TYPE_DATETIME: case MYSQLI_TYPE_TIMESTAMP: $cell = mktime ( substr ($cell, 11 , 2) ,substr ($cell, 14 , 2) ,substr ($cell, 17 , 2) ,substr ($cell, 5 , 2) ,substr ($cell, 8 , 2) ,substr ($cell, 0 , 4) ); break; case MYSQLI_TYPE_BIT: $cell = (bool) $cell; break; case MYSQLI_TYPE_TINY: case MYSQLI_TYPE_SHORT: case MYSQLI_TYPE_LONG: case MYSQLI_TYPE_LONGLONG: case MYSQLI_TYPE_INT24: case MYSQLI_TYPE_YEAR: $cell = (int) $cell; break; case MYSQLI_TYPE_FLOAT: case MYSQLI_TYPE_DOUBLE: case MYSQLI_TYPE_DECIMAL: case MYSQLI_TYPE_NEWDECIMAL: $cell = (float) $cell; break; } } $resultMap['data'][] = $row; } $results[] = $resultMap; $result->free (); } else $results[] = TRUE; } while ($conn->moreResults () && $conn->nextResult ()); } catch (Db\Exception $e) { throw new Rest\Exception ('Conn', $e->getCode (), $e->getMessage ()); } return $results; } } ?>