1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

Non-MySQL: Better field types in SQL command

This commit is contained in:
Jakub Vrana
2025-03-24 14:41:08 +01:00
parent f5d23a8cad
commit 50cdbbe415
7 changed files with 10 additions and 9 deletions

View File

@@ -140,7 +140,7 @@ if (isset($_GET["mssql"])) {
$field = $this->fields[$this->offset++]; $field = $this->fields[$this->offset++];
$return = new \stdClass; $return = new \stdClass;
$return->name = $field["Name"]; $return->name = $field["Name"];
$return->type = ($field["Type"] == 1 ? 254 : 0); $return->type = ($field["Type"] == 1 ? 254 : 15);
$return->charsetnr = 0; $return->charsetnr = 0;
return $return; return $return;
} }

View File

@@ -219,7 +219,7 @@ if (!defined('Adminer\DRIVER')) {
} }
/** Fetch next field /** Fetch next field
* @return object properties: name, type (9 for number, 254 for char), charsetnr (63 for binary); optionally: table, orgtable, orgname * @return object properties: name, type (0 number, 15 varchar, 254 char), charsetnr (63 binary); optionally: table, orgtable, orgname
*/ */
function fetch_field() { function fetch_field() {
$return = mysql_fetch_field($this->result, $this->offset++); // offset required under certain conditions $return = mysql_fetch_field($this->result, $this->offset++); // offset required under certain conditions

View File

@@ -70,10 +70,10 @@ if (isset($_GET["sqlite"])) {
function fetch_field() { function fetch_field() {
$column = $this->offset++; $column = $this->offset++;
$type = $this->result->columnType($column); //! map to MySQL numbers $type = $this->result->columnType($column);
return (object) array( return (object) array(
"name" => $this->result->columnName($column), "name" => $this->result->columnName($column),
"type" => $type, "type" => ($type == SQLITE3_TEXT ? 15 : 0),
"charsetnr" => ($type == SQLITE3_BLOB ? 63 : 0), // 63 - binary "charsetnr" => ($type == SQLITE3_BLOB ? 63 : 0), // 63 - binary
); );
} }

View File

@@ -93,8 +93,9 @@ if (extension_loaded('pdo')) {
function fetch_field() { function fetch_field() {
$row = (object) $this->getColumnMeta($this->_offset++); $row = (object) $this->getColumnMeta($this->_offset++);
$row->type = $row->pdo_type; //! map to MySQL numbers $type = $row->pdo_type;
$row->charsetnr = (isset($row->flags) && in_array("blob", (array) $row->flags) ? 63 : 0); $row->type = ($type == \PDO::PARAM_INT ? 0 : 15);
$row->charsetnr = ($type == \PDO::PARAM_LOB || (isset($row->flags) && in_array("blob", (array) $row->flags)) ? 63 : 0);
return $row; return $row;
} }

View File

@@ -139,7 +139,7 @@ if (isset($_GET["imap"])) {
function fetch_field() { function fetch_field() {
$field = current($this->fields); $field = current($this->fields);
next($this->fields); next($this->fields);
return ($field != '' ? (object) array('name' => $field, 'type' => 0, 'charsetnr' => 0) : false); return ($field != '' ? (object) array('name' => $field, 'type' => 15, 'charsetnr' => 0) : false);
} }
} }
} }

View File

@@ -112,7 +112,7 @@ if (isset($_GET["mongo"])) {
$name = $keys[$this->offset++]; $name = $keys[$this->offset++];
return (object) array( return (object) array(
'name' => $name, 'name' => $name,
'type' => 0, 'type' => 15,
'charsetnr' => $this->charset[$name], 'charsetnr' => $this->charset[$name],
); );
} }

View File

@@ -112,7 +112,7 @@ if (isset($_GET["simpledb"])) {
function fetch_field() { function fetch_field() {
$keys = array_keys($this->rows[0]); $keys = array_keys($this->rows[0]);
return (object) array('name' => $keys[$this->offset++], 'type' => 0, 'charsetnr' => 0); return (object) array('name' => $keys[$this->offset++], 'type' => 15, 'charsetnr' => 0);
} }
} }
} }