@@ 115-133 (lines=19) @@ | ||
112 | * |
|
113 | * @return array[] |
|
114 | */ |
|
115 | public function getListColumns () |
|
116 | { |
|
117 | $sqlTables = !empty($this->tablesName)?"AND table_name IN ( $this->tablesName )":''; |
|
118 | ||
119 | return $this->getPDO () |
|
120 | ->query ( |
|
121 | "select |
|
122 | 0 AS table_schema, |
|
123 | table_name, |
|
124 | column_name , |
|
125 | column_default, |
|
126 | data_type, |
|
127 | is_nullable, |
|
128 | character_maximum_length AS max_length |
|
129 | from information_schema.columns |
|
130 | where table_schema IN ('{$this->database}') $sqlTables |
|
131 | order by table_name,ordinal_position" |
|
132 | ) |
|
133 | ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
134 | } |
|
135 | ||
136 | /** |
|
@@ 139-164 (lines=26) @@ | ||
136 | /** |
|
137 | * @return array |
|
138 | */ |
|
139 | public function getListConstrant () |
|
140 | { |
|
141 | $sqlTables = !empty($this->tablesName)?"AND k.table_name IN ( $this->tablesName )":''; |
|
142 | ||
143 | $objQuery = $this->getPDO () |
|
144 | ->query ( |
|
145 | "SELECT distinct |
|
146 | i.constraint_type, |
|
147 | k.constraint_name, |
|
148 | -- k.table_schema, |
|
149 | 0 AS table_schema, |
|
150 | k.table_name, |
|
151 | k.column_name, |
|
152 | -- k.REFERENCED_TABLE_SCHEMA AS foreign_schema, |
|
153 | 0 AS foreign_schema, |
|
154 | k.REFERENCED_TABLE_NAME AS foreign_table, |
|
155 | k.REFERENCED_COLUMN_NAME AS foreign_column |
|
156 | FROM information_schema.TABLE_CONSTRAINTS as i |
|
157 | inner join information_schema.key_column_usage as k |
|
158 | ON i.CONSTRAINT_NAME = k.CONSTRAINT_NAME and k.TABLE_SCHEMA <> 'mysql' |
|
159 | WHERE |
|
160 | i.TABLE_SCHEMA IN ('{$this->database}') AND i.CONSTRAINT_TYPE IN ('FOREIGN KEY', 'PRIMARY KEY' ) $sqlTables |
|
161 | order by k.table_name;" |
|
162 | ); |
|
163 | return $objQuery?$objQuery->fetchAll ( \PDO::FETCH_ASSOC ):array(); |
|
164 | } |
|
165 | ||
166 | /** |
|
167 | * retorna o numero total de tabelas |
@@ 109-131 (lines=23) @@ | ||
106 | * |
|
107 | * @return array |
|
108 | */ |
|
109 | public function getListColumns () |
|
110 | { |
|
111 | $sqlTables = !empty($this->tablesName)?"AND c.table_name IN ( $this->tablesName )":''; |
|
112 | $strSchema = implode ( "', '", $this->schema ); |
|
113 | ||
114 | return $this->getPDO () |
|
115 | ->query ( |
|
116 | "SELECT distinct |
|
117 | c.table_schema, |
|
118 | c.table_name, |
|
119 | c.column_name , |
|
120 | c.data_type, |
|
121 | c.column_default, |
|
122 | is_nullable, |
|
123 | character_maximum_length AS max_length |
|
124 | FROM |
|
125 | information_schema.tables AS st |
|
126 | INNER JOIN information_schema.columns AS c |
|
127 | ON st.table_name=c.table_name and st.table_type = 'BASE TABLE' |
|
128 | $sqlTables and c.table_schema IN ('$strSchema') |
|
129 | order by c.table_name asc" |
|
130 | ) |
|
131 | ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
132 | } |
|
133 | ||
134 | public function getListConstrant () |
|
@@ 134-163 (lines=30) @@ | ||
131 | ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
132 | } |
|
133 | ||
134 | public function getListConstrant () |
|
135 | { |
|
136 | $sqlTables = !empty($this->tablesName)?"AND tc.table_name IN ( $this->tablesName )":''; |
|
137 | $strSchema = implode ( "', '", $this->schema ); |
|
138 | ||
139 | return $this->getPDO () |
|
140 | ->query ( |
|
141 | "SELECT distinct |
|
142 | tc.constraint_type, |
|
143 | tc.constraint_name, |
|
144 | tc.table_schema, |
|
145 | tc.table_name, |
|
146 | kcu.column_name, |
|
147 | ccu.table_schema AS foreign_schema, |
|
148 | ccu.table_name AS foreign_table, |
|
149 | ccu.column_name as foreign_column |
|
150 | FROM |
|
151 | information_schema.table_constraints AS tc |
|
152 | JOIN information_schema.key_column_usage AS kcu |
|
153 | ON tc.constraint_name = kcu.constraint_name |
|
154 | AND tc.table_schema IN ('$strSchema') |
|
155 | AND tc.constraint_type IN ('FOREIGN KEY','PRIMARY KEY') |
|
156 | $sqlTables |
|
157 | JOIN information_schema.constraint_column_usage AS ccu |
|
158 | ON tc.constraint_name = ccu.constraint_name |
|
159 | AND tc.constraint_schema = ccu.constraint_schema |
|
160 | ORDER by tc.table_schema" |
|
161 | ) |
|
162 | ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
163 | } |
|
164 | ||
165 | /** |
|
166 | * Retorna o Nome da Sequence da tabela |