@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | */ |
25 | 25 | protected $port; |
26 | 26 | |
27 | - protected $schema = array ( 'public' ); |
|
27 | + protected $schema = array('public'); |
|
28 | 28 | |
29 | - public function __construct ( AbstractAdapter $adapterConfig ) |
|
29 | + public function __construct(AbstractAdapter $adapterConfig) |
|
30 | 30 | { |
31 | - parent::__construct ( $adapterConfig ); |
|
32 | - if ( $adapterConfig->hasSchemas () ) { |
|
33 | - $this->schema = $adapterConfig->getSchemas (); |
|
31 | + parent::__construct($adapterConfig); |
|
32 | + if ($adapterConfig->hasSchemas()) { |
|
33 | + $this->schema = $adapterConfig->getSchemas(); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | } |
@@ -38,33 +38,33 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * @inheritDoc |
40 | 40 | */ |
41 | - protected function convertTypeToSimple ( $str ) |
|
41 | + protected function convertTypeToSimple($str) |
|
42 | 42 | { |
43 | - if ( preg_match ( '/(tinyint|bit)/' , $str ) ) |
|
43 | + if (preg_match('/(tinyint|bit)/', $str)) |
|
44 | 44 | { |
45 | 45 | $res = 'boolean'; |
46 | - } elseif ( preg_match ( '/(date|time|text|binary|char|xml|uniqueidentifier)/' , $str ) ) |
|
46 | + } elseif (preg_match('/(date|time|text|binary|char|xml|uniqueidentifier)/', $str)) |
|
47 | 47 | { |
48 | 48 | $res = 'string'; |
49 | - } elseif ( preg_match ( '/(decimal|numeric|real|float|money)/' , $str ) ) |
|
49 | + } elseif (preg_match('/(decimal|numeric|real|float|money)/', $str)) |
|
50 | 50 | { |
51 | 51 | $res = 'float'; |
52 | - } elseif ( preg_match ( '#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#' , $str , $matches ) ) |
|
52 | + } elseif (preg_match('#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches)) |
|
53 | 53 | { |
54 | - $res = $matches[ 1 ]; |
|
54 | + $res = $matches[1]; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | return $res; |
58 | 58 | } |
59 | 59 | |
60 | - protected function getHost(){ |
|
60 | + protected function getHost() { |
|
61 | 61 | $host = $this->host; |
62 | - if (!empty($this->port)) { |
|
62 | + if ( ! empty($this->port)) { |
|
63 | 63 | $seperator = ':'; |
64 | 64 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
65 | 65 | $seperator = ','; |
66 | 66 | } |
67 | - $host .= $seperator . $this->port; |
|
67 | + $host .= $seperator . $this->port; |
|
68 | 68 | unset($this->port); |
69 | 69 | } |
70 | 70 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @inheritDoc |
76 | 76 | * @return string |
77 | 77 | */ |
78 | - public function getPDOString () |
|
78 | + public function getPDOString() |
|
79 | 79 | { |
80 | - return sprintf ( |
|
81 | - "mssql:host=%s;dbname=%s" , |
|
82 | - $this->getHost() , |
|
80 | + return sprintf( |
|
81 | + "mssql:host=%s;dbname=%s", |
|
82 | + $this->getHost(), |
|
83 | 83 | $this->database |
84 | 84 | ); |
85 | 85 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @inheritDoc |
89 | 89 | * @return string |
90 | 90 | */ |
91 | - public function getPDOSocketString () |
|
91 | + public function getPDOSocketString() |
|
92 | 92 | { |
93 | 93 | // TODO: implement here |
94 | 94 | return ""; |
@@ -98,18 +98,18 @@ discard block |
||
98 | 98 | * @inheritDoc |
99 | 99 | * @return string[] |
100 | 100 | */ |
101 | - public function getListNameTable () |
|
101 | + public function getListNameTable() |
|
102 | 102 | { |
103 | - if ( empty( $this->tableList ) ) |
|
103 | + if (empty($this->tableList)) |
|
104 | 104 | { |
105 | 105 | |
106 | - $sqlTables = ! empty( $this->tablesName ) |
|
106 | + $sqlTables = ! empty($this->tablesName) |
|
107 | 107 | ? "AND table_name IN ( $this->tablesName )" : ''; |
108 | 108 | |
109 | - $strSchema = implode ( "', '" , $this->schema ); |
|
109 | + $strSchema = implode("', '", $this->schema); |
|
110 | 110 | |
111 | - $this->tableList = $this->getPDO () |
|
112 | - ->query ( |
|
111 | + $this->tableList = $this->getPDO() |
|
112 | + ->query( |
|
113 | 113 | "SELECT table_schema, |
114 | 114 | table_name |
115 | 115 | FROM {$this->database}.information_schema.tables |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | table_name |
122 | 122 | ASC" |
123 | 123 | ) |
124 | - ->fetchAll (); |
|
124 | + ->fetchAll(); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | return $this->tableList; |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @return array |
140 | 140 | */ |
141 | - public function getListColumns () |
|
141 | + public function getListColumns() |
|
142 | 142 | { |
143 | - $sqlTables = ! empty( $this->tablesName ) |
|
143 | + $sqlTables = ! empty($this->tablesName) |
|
144 | 144 | ? "AND c.table_name IN ( $this->tablesName )" : ''; |
145 | - $strSchema = implode ( "', '" , $this->schema ); |
|
145 | + $strSchema = implode("', '", $this->schema); |
|
146 | 146 | |
147 | - return $this->getPDO () |
|
148 | - ->query ( |
|
147 | + return $this->getPDO() |
|
148 | + ->query( |
|
149 | 149 | "SELECT distinct |
150 | 150 | c.table_schema, |
151 | 151 | c.table_name, |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $sqlTables and c.table_schema IN ('$strSchema') |
161 | 161 | order by c.table_name asc" |
162 | 162 | ) |
163 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
163 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -168,38 +168,38 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return int |
170 | 170 | */ |
171 | - public function getTotalTables () |
|
171 | + public function getTotalTables() |
|
172 | 172 | { |
173 | - if ( empty( $this->totalTables ) ) |
|
173 | + if (empty($this->totalTables)) |
|
174 | 174 | { |
175 | - $sqlTables = ! empty( $this->tablesName ) |
|
175 | + $sqlTables = ! empty($this->tablesName) |
|
176 | 176 | ? "AND table_name IN ( $this->tablesName )" : ''; |
177 | 177 | |
178 | - $strSchema = implode ( "', '" , $this->schema ); |
|
178 | + $strSchema = implode("', '", $this->schema); |
|
179 | 179 | |
180 | - $this->totalTables = $this->getPDO () |
|
181 | - ->query ( |
|
180 | + $this->totalTables = $this->getPDO() |
|
181 | + ->query( |
|
182 | 182 | "SELECT COUNT(table_name) AS total |
183 | 183 | FROM {$this->database}.information_schema.tables |
184 | 184 | WHERE |
185 | 185 | table_type = 'BASE TABLE' |
186 | 186 | AND table_schema IN ( '" . $strSchema . "' ) $sqlTables" |
187 | 187 | ) |
188 | - ->fetchColumn (); |
|
188 | + ->fetchColumn(); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | return (int) $this->totalTables; |
192 | 192 | } |
193 | 193 | |
194 | - public function getSequence ( $table , $column , $schema = 0 ) |
|
194 | + public function getSequence($table, $column, $schema = 0) |
|
195 | 195 | { |
196 | - $return = $this->getPDO () |
|
197 | - ->query ( |
|
196 | + $return = $this->getPDO() |
|
197 | + ->query( |
|
198 | 198 | "SELECT is_identity FROM sys.columns WHERE object_id = object_id('{$schema}.{$table}') AND name = '{$column}';" |
199 | 199 | ) |
200 | 200 | ->fetchColumn(); |
201 | 201 | |
202 | - if ( ! $return ) |
|
202 | + if ( ! $return) |
|
203 | 203 | { |
204 | 204 | return; |
205 | 205 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * @return array |
212 | 212 | */ |
213 | - public function getListConstrant () |
|
213 | + public function getListConstrant() |
|
214 | 214 | { |
215 | 215 | return array(); |
216 | 216 | } |