@@ -94,84 +94,93 @@ public function column(string $db, string $table, string $column): void
9494 * @param string $db database name
9595 * @param string $table table name
9696 */
97- public function table ($ db , $ table ): void
97+ public function table (string $ db , string $ table ): void
9898 {
9999 $ relationParameters = $ this ->relation ->getRelationParameters ();
100+ $ columnCommentsFeature = $ relationParameters ->columnCommentsFeature ;
101+ $ displayFeature = $ relationParameters ->displayFeature ;
102+ $ pdfFeature = $ relationParameters ->pdfFeature ;
103+ $ relationFeature = $ relationParameters ->relationFeature ;
104+ $ uiPreferencesFeature = $ relationParameters ->uiPreferencesFeature ;
105+ $ navigationItemsHidingFeature = $ relationParameters ->navigationItemsHidingFeature ;
100106
101- if ($ relationParameters ->columnCommentsFeature !== null ) {
102- $ remove_query = 'DELETE FROM '
103- . Util::backquote ($ relationParameters ->columnCommentsFeature ->database )
104- . '. ' . Util::backquote ($ relationParameters ->columnCommentsFeature ->columnInfo )
105- . ' WHERE db_name = \'' . $ this ->dbi ->escapeString ($ db ) . '\''
106- . ' AND table_name = \'' . $ this ->dbi ->escapeString ($ table )
107- . '\'' ;
108- $ this ->dbi ->queryAsControlUser ($ remove_query );
107+ if ($ columnCommentsFeature !== null ) {
108+ $ statement = sprintf (
109+ 'DELETE FROM %s.%s WHERE db_name = %s AND table_name = %s ' ,
110+ Util::backquote ($ columnCommentsFeature ->database ),
111+ Util::backquote ($ columnCommentsFeature ->columnInfo ),
112+ $ this ->dbi ->quoteString ($ db ),
113+ $ this ->dbi ->quoteString ($ table ),
114+ );
115+ $ this ->dbi ->queryAsControlUser ($ statement );
109116 }
110117
111- if ($ relationParameters ->displayFeature !== null ) {
112- $ remove_query = 'DELETE FROM '
113- . Util::backquote ($ relationParameters ->displayFeature ->database )
114- . '. ' . Util::backquote ($ relationParameters ->displayFeature ->tableInfo )
115- . ' WHERE db_name = \'' . $ this ->dbi ->escapeString ($ db ) . '\''
116- . ' AND table_name = \'' . $ this ->dbi ->escapeString ($ table )
117- . '\'' ;
118- $ this ->dbi ->queryAsControlUser ($ remove_query );
118+ if ($ displayFeature !== null ) {
119+ $ statement = sprintf (
120+ 'DELETE FROM %s.%s WHERE db_name = %s AND table_name = %s ' ,
121+ Util::backquote ($ displayFeature ->database ),
122+ Util::backquote ($ displayFeature ->tableInfo ),
123+ $ this ->dbi ->quoteString ($ db ),
124+ $ this ->dbi ->quoteString ($ table ),
125+ );
126+ $ this ->dbi ->queryAsControlUser ($ statement );
119127 }
120128
121- if ($ relationParameters ->pdfFeature !== null ) {
122- $ remove_query = 'DELETE FROM '
123- . Util::backquote ($ relationParameters ->pdfFeature ->database )
124- . '. ' . Util::backquote ($ relationParameters ->pdfFeature ->tableCoords )
125- . ' WHERE db_name = \'' . $ this ->dbi ->escapeString ($ db ) . '\''
126- . ' AND table_name = \'' . $ this ->dbi ->escapeString ($ table )
127- . '\'' ;
128- $ this ->dbi ->queryAsControlUser ($ remove_query );
129+ if ($ pdfFeature !== null ) {
130+ $ statement = sprintf (
131+ 'DELETE FROM %s.%s WHERE db_name = %s AND table_name = %s ' ,
132+ Util::backquote ($ pdfFeature ->database ),
133+ Util::backquote ($ pdfFeature ->tableCoords ),
134+ $ this ->dbi ->quoteString ($ db ),
135+ $ this ->dbi ->quoteString ($ table ),
136+ );
137+ $ this ->dbi ->queryAsControlUser ($ statement );
129138 }
130139
131- if ($ relationParameters -> relationFeature !== null ) {
132- $ remove_query = ' DELETE FROM '
133- . Util:: backquote ( $ relationParameters -> relationFeature -> database )
134- . ' . ' . Util::backquote ($ relationParameters -> relationFeature ->relation )
135- . ' WHERE master_db = \'' . $ this -> dbi -> escapeString ( $ db )
136- . '\''
137- . ' AND master_table = \'' . $ this ->dbi ->escapeString ($ table )
138- . '\'' ;
139- $ this ->dbi ->queryAsControlUser ($ remove_query );
140+ if ($ relationFeature !== null ) {
141+ $ statement = sprintf (
142+ ' DELETE FROM %s.%s WHERE master_db = %s AND master_table = %s ' ,
143+ Util::backquote ($ relationFeature ->database ),
144+ Util:: backquote ( $ relationFeature -> relation ),
145+ $ this -> dbi -> quoteString ( $ db ),
146+ $ this ->dbi ->quoteString ($ table ),
147+ ) ;
148+ $ this ->dbi ->queryAsControlUser ($ statement );
140149
141- $ remove_query = ' DELETE FROM '
142- . Util:: backquote ( $ relationParameters -> relationFeature -> database )
143- . ' . ' . Util::backquote ($ relationParameters -> relationFeature ->relation )
144- . ' WHERE foreign_db = \'' . $ this -> dbi -> escapeString ( $ db )
145- . '\''
146- . ' AND foreign_table = \'' . $ this ->dbi ->escapeString ($ table )
147- . '\'' ;
148- $ this ->dbi ->queryAsControlUser ($ remove_query );
150+ $ statement = sprintf (
151+ ' DELETE FROM %s.%s WHERE foreign_db = %s AND foreign_table = %s ' ,
152+ Util::backquote ($ relationFeature ->database ),
153+ Util:: backquote ( $ relationFeature -> relation ),
154+ $ this -> dbi -> quoteString ( $ db ),
155+ $ this ->dbi ->quoteString ($ table ),
156+ ) ;
157+ $ this ->dbi ->queryAsControlUser ($ statement );
149158 }
150159
151- if ($ relationParameters ->uiPreferencesFeature !== null ) {
152- $ remove_query = 'DELETE FROM '
153- . Util::backquote ($ relationParameters ->uiPreferencesFeature ->database )
154- . '. ' . Util::backquote ($ relationParameters ->uiPreferencesFeature ->tableUiPrefs )
155- . ' WHERE db_name = \'' . $ this ->dbi ->escapeString ($ db ) . '\''
156- . ' AND table_name = \'' . $ this ->dbi ->escapeString ($ table )
157- . '\'' ;
158- $ this ->dbi ->queryAsControlUser ($ remove_query );
160+ if ($ uiPreferencesFeature !== null ) {
161+ $ statement = sprintf (
162+ 'DELETE FROM %s.%s WHERE db_name = %s AND table_name = %s ' ,
163+ Util::backquote ($ uiPreferencesFeature ->database ),
164+ Util::backquote ($ uiPreferencesFeature ->tableUiPrefs ),
165+ $ this ->dbi ->quoteString ($ db ),
166+ $ this ->dbi ->quoteString ($ table ),
167+ );
168+ $ this ->dbi ->queryAsControlUser ($ statement );
159169 }
160170
161- if ($ relationParameters -> navigationItemsHidingFeature === null ) {
171+ if ($ navigationItemsHidingFeature === null ) {
162172 return ;
163173 }
164174
165- $ remove_query = 'DELETE FROM '
166- . Util::backquote ($ relationParameters ->navigationItemsHidingFeature ->database )
167- . '. ' . Util::backquote ($ relationParameters ->navigationItemsHidingFeature ->navigationHiding )
168- . ' WHERE db_name = \'' . $ this ->dbi ->escapeString ($ db ) . '\''
169- . ' AND (table_name = \'' . $ this ->dbi ->escapeString ($ table )
170- . '\''
171- . ' OR (item_name = \'' . $ this ->dbi ->escapeString ($ table )
172- . '\''
173- . ' AND item_type = \'table \')) ' ;
174- $ this ->dbi ->queryAsControlUser ($ remove_query );
175+ $ statement = sprintf (
176+ 'DELETE FROM %s.%s WHERE db_name = %s AND (table_name = %s OR (item_name = %s AND item_type = \'table \')) ' ,
177+ Util::backquote ($ navigationItemsHidingFeature ->database ),
178+ Util::backquote ($ navigationItemsHidingFeature ->navigationHiding ),
179+ $ this ->dbi ->quoteString ($ db ),
180+ $ this ->dbi ->quoteString ($ table ),
181+ $ this ->dbi ->quoteString ($ table ),
182+ );
183+ $ this ->dbi ->queryAsControlUser ($ statement );
175184 }
176185
177186 /**
0 commit comments