mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-09-02 13:31:38 +08:00
改进数据库驱动的getFields方法 支持指定别名的情况 修正model类一处错误
This commit is contained in:
@@ -42,6 +42,7 @@ class Mysql extends Driver{
|
||||
*/
|
||||
public function getFields($tableName) {
|
||||
$this->initConnect(true);
|
||||
list($tableName) = explode(' ', $tableName);
|
||||
$sql = 'SHOW COLUMNS FROM `'.$tableName.'`';
|
||||
$result = $this->query($sql);
|
||||
$info = [];
|
||||
|
||||
@@ -80,6 +80,7 @@ class Oracle extends Driver{
|
||||
* @access public
|
||||
*/
|
||||
public function getFields($tableName) {
|
||||
list($tableName) = explode(' ', $tableName);
|
||||
$result = $this->query("select a.column_name,data_type,decode(nullable,'Y',0,1) notnull,data_default,decode(a.column_name,b.column_name,1,0) pk "
|
||||
."from user_tab_columns a,(select column_name from user_constraints c,user_cons_columns col "
|
||||
."where c.constraint_name=col.constraint_name and c.constraint_type='P'and c.table_name='".strtoupper($tableName)
|
||||
|
||||
@@ -37,6 +37,7 @@ class Pgsql extends Driver{
|
||||
* @return array
|
||||
*/
|
||||
public function getFields($tableName) {
|
||||
list($tableName) = explode(' ', $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 = [];
|
||||
if($result){
|
||||
|
||||
@@ -34,6 +34,7 @@ class Sqlite extends Driver {
|
||||
* @return array
|
||||
*/
|
||||
public function getFields($tableName) {
|
||||
list($tableName) = explode(' ', $tableName);
|
||||
$result = $this->query('PRAGMA table_info( '.$tableName.' )');
|
||||
$info = [];
|
||||
if($result){
|
||||
|
||||
@@ -46,6 +46,7 @@ class Sqlsrv extends Driver{
|
||||
* @return array
|
||||
*/
|
||||
public function getFields($tableName) {
|
||||
list($tableName) = explode(' ', $tableName);
|
||||
$result = $this->query("SELECT column_name, data_type, column_default, is_nullable
|
||||
FROM information_schema.tables AS t
|
||||
JOIN information_schema.columns AS c
|
||||
|
||||
Reference in New Issue
Block a user