mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
改进数据库驱动类
This commit is contained in:
@@ -25,17 +25,17 @@ class Pgsql extends Driver{
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getFields($tableName) {
|
public function getFields($tableName) {
|
||||||
$result = $this->query('select fields_name as "Field",fields_type as "Type",fields_not_null as "Null",fields_key_name as "Key",fields_default as "Default",fields_default as "Extra" from table_msg('.$tableName.');');
|
$result = $this->query('select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra" from table_msg('.$tableName.');');
|
||||||
$info = [];
|
$info = [];
|
||||||
if($result){
|
if($result){
|
||||||
foreach ($result as $key => $val) {
|
foreach ($result as $key => $val) {
|
||||||
$info[$val['Field']] = array(
|
$info[$val['field']] = array(
|
||||||
'name' => $val['Field'],
|
'name' => $val['field'],
|
||||||
'type' => $val['Type'],
|
'type' => $val['type'],
|
||||||
'notnull' => (bool) ($val['Null'] === ''), // not null is empty, null is yes
|
'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes
|
||||||
'default' => $val['Default'],
|
'default' => $val['default'],
|
||||||
'primary' => (strtolower($val['Key']) == 'pri'),
|
'primary' => (strtolower($val['key']) == 'pri'),
|
||||||
'autoinc' => (strtolower($val['Extra']) == 'auto_increment'),
|
'autoinc' => (strtolower($val['extra']) == 'auto_increment'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ class Sqlite extends Driver {
|
|||||||
$info = [];
|
$info = [];
|
||||||
if($result){
|
if($result){
|
||||||
foreach ($result as $key => $val) {
|
foreach ($result as $key => $val) {
|
||||||
$info[$val['Field']] = array(
|
$info[$val['field']] = array(
|
||||||
'name' => $val['Field'],
|
'name' => $val['field'],
|
||||||
'type' => $val['Type'],
|
'type' => $val['type'],
|
||||||
'notnull' => (bool) ($val['Null'] === ''), // not null is empty, null is yes
|
'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes
|
||||||
'default' => $val['Default'],
|
'default' => $val['default'],
|
||||||
'primary' => (strtolower($val['Key']) == 'pri'),
|
'primary' => (strtolower($val['dey']) == 'pri'),
|
||||||
'autoinc' => (strtolower($val['Extra']) == 'auto_increment'),
|
'autoinc' => (strtolower($val['extra']) == 'auto_increment'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user