1010use PhpMyAdmin \Controllers \Database \ExportController as DatabaseExportController ;
1111use PhpMyAdmin \Controllers \Server \ExportController as ServerExportController ;
1212use PhpMyAdmin \Controllers \Table \ExportController as TableExportController ;
13+ use PhpMyAdmin \Dbal \DatabaseName ;
1314use PhpMyAdmin \Plugins \ExportPlugin ;
1415use PhpMyAdmin \Plugins \SchemaPlugin ;
1516
@@ -599,7 +600,7 @@ public function exportServer(
599600
600601 $ tables = $ this ->dbi ->getTables ($ currentDb );
601602 $ this ->exportDatabase (
602- $ currentDb ,
603+ DatabaseName:: fromValue ( $ currentDb) ,
603604 $ tables ,
604605 $ whatStrucOrData ,
605606 $ tables ,
@@ -625,7 +626,7 @@ public function exportServer(
625626 /**
626627 * Export at the database level
627628 *
628- * @param string $db the database to export
629+ * @param DatabaseName $db the database to export
629630 * @param array $tables the tables to export
630631 * @param string $whatStrucOrData structure or data or both
631632 * @param array $tableStructure whether to export structure for each table
@@ -641,7 +642,7 @@ public function exportServer(
641642 * @param string $separateFiles whether it is a separate-files export
642643 */
643644 public function exportDatabase (
644- string $ db ,
645+ DatabaseName $ db ,
645646 array $ tables ,
646647 string $ whatStrucOrData ,
647648 array $ tableStructure ,
@@ -656,14 +657,14 @@ public function exportDatabase(
656657 array $ aliases ,
657658 string $ separateFiles
658659 ): void {
659- $ dbAlias = ! empty ($ aliases [$ db ]['alias ' ])
660- ? $ aliases [$ db ]['alias ' ] : '' ;
660+ $ dbAlias = ! empty ($ aliases [$ db-> getName () ]['alias ' ])
661+ ? $ aliases [$ db-> getName () ]['alias ' ] : '' ;
661662
662- if (! $ exportPlugin ->exportDBHeader ($ db , $ dbAlias )) {
663+ if (! $ exportPlugin ->exportDBHeader ($ db-> getName () , $ dbAlias )) {
663664 return ;
664665 }
665666
666- if (! $ exportPlugin ->exportDBCreate ($ db , $ exportType , $ dbAlias )) {
667+ if (! $ exportPlugin ->exportDBCreate ($ db-> getName () , $ exportType , $ dbAlias )) {
667668 return ;
668669 }
669670
@@ -676,7 +677,7 @@ public function exportDatabase(
676677 || $ GLOBALS ['sql_structure_or_data ' ] === 'structure_and_data ' )
677678 && isset ($ GLOBALS ['sql_procedure_function ' ])
678679 ) {
679- $ exportPlugin ->exportRoutines ($ db , $ aliases );
680+ $ exportPlugin ->exportRoutines ($ db-> getName () , $ aliases );
680681
681682 if ($ separateFiles === 'database ' ) {
682683 $ this ->saveObjectInBuffer ('routines ' );
@@ -686,7 +687,7 @@ public function exportDatabase(
686687 $ views = [];
687688
688689 foreach ($ tables as $ table ) {
689- $ tableObject = new Table ($ table , $ db , $ this ->dbi );
690+ $ tableObject = new Table ($ table , $ db-> getName () , $ this ->dbi );
690691 // if this is a view, collect it for later;
691692 // views must be exported after the tables
692693 $ isView = $ tableObject ->isView ();
@@ -706,7 +707,7 @@ public function exportDatabase(
706707 $ separateFiles == ''
707708 && isset ($ GLOBALS ['sql_create_view ' ])
708709 && ! $ exportPlugin ->exportStructure (
709- $ db ,
710+ $ db-> getName () ,
710711 $ table ,
711712 $ errorUrl ,
712713 'stand_in ' ,
@@ -728,7 +729,7 @@ public function exportDatabase(
728729 // This obtains the current table's size
729730 $ query = 'SELECT data_length + index_length
730731 from information_schema.TABLES
731- WHERE table_schema = " ' . $ this ->dbi ->escapeString ($ db ) . '"
732+ WHERE table_schema = " ' . $ this ->dbi ->escapeString ($ db-> getName () ) . '"
732733 AND table_name = " ' . $ this ->dbi ->escapeString ($ table ) . '" ' ;
733734
734735 $ size = (int ) $ this ->dbi ->fetchValue ($ query );
@@ -741,7 +742,7 @@ public function exportDatabase(
741742
742743 if (
743744 ! $ exportPlugin ->exportStructure (
744- $ db ,
745+ $ db-> getName () ,
745746 $ table ,
746747 $ errorUrl ,
747748 'create_table ' ,
@@ -764,14 +765,14 @@ public function exportDatabase(
764765 && in_array ($ table , $ tableData )
765766 && ! $ isView
766767 ) {
767- $ tableObj = new Table ($ table , $ db , $ this ->dbi );
768+ $ tableObj = new Table ($ table , $ db-> getName () , $ this ->dbi );
768769 $ nonGeneratedCols = $ tableObj ->getNonGeneratedColumns (true );
769770
770771 $ localQuery = 'SELECT ' . implode (', ' , $ nonGeneratedCols )
771- . ' FROM ' . Util::backquote ($ db )
772+ . ' FROM ' . Util::backquote ($ db-> getName () )
772773 . '. ' . Util::backquote ($ table );
773774
774- if (! $ exportPlugin ->exportData ($ db , $ table , $ errorUrl , $ localQuery , $ aliases )) {
775+ if (! $ exportPlugin ->exportData ($ db-> getName () , $ table , $ errorUrl , $ localQuery , $ aliases )) {
775776 break ;
776777 }
777778 }
@@ -793,7 +794,7 @@ public function exportDatabase(
793794
794795 if (
795796 ! $ exportPlugin ->exportStructure (
796- $ db ,
797+ $ db-> getName () ,
797798 $ table ,
798799 $ errorUrl ,
799800 'triggers ' ,
@@ -824,7 +825,7 @@ public function exportDatabase(
824825
825826 if (
826827 ! $ exportPlugin ->exportStructure (
827- $ db ,
828+ $ db-> getName () ,
828829 $ view ,
829830 $ errorUrl ,
830831 'create_view ' ,
@@ -847,7 +848,7 @@ public function exportDatabase(
847848 }
848849 }
849850
850- if (! $ exportPlugin ->exportDBFooter ($ db )) {
851+ if (! $ exportPlugin ->exportDBFooter ($ db-> getName () )) {
851852 return ;
852853 }
853854
@@ -856,7 +857,7 @@ public function exportDatabase(
856857 // Types of metadata to export.
857858 // In the future these can be allowed to be selected by the user
858859 $ metadataTypes = $ this ->getMetadataTypes ();
859- $ exportPlugin ->exportMetadata ($ db , $ tables , $ metadataTypes );
860+ $ exportPlugin ->exportMetadata ($ db-> getName () , $ tables , $ metadataTypes );
860861
861862 if ($ separateFiles === 'database ' ) {
862863 $ this ->saveObjectInBuffer ('metadata ' );
@@ -875,7 +876,7 @@ public function exportDatabase(
875876 return ;
876877 }
877878
878- $ exportPlugin ->exportEvents ($ db );
879+ $ exportPlugin ->exportEvents ($ db-> getName () );
879880
880881 if ($ separateFiles !== 'database ' ) {
881882 return ;
@@ -1167,17 +1168,17 @@ public function mergeAliases(array $aliases1, array $aliases2): array
11671168 /**
11681169 * Locks tables
11691170 *
1170- * @param string $db database name
1171- * @param array $tables list of table names
1172- * @param string $lockType lock type; "[LOW_PRIORITY] WRITE" or "READ [LOCAL]"
1171+ * @param DatabaseName $db database name
1172+ * @param array $tables list of table names
1173+ * @param string $lockType lock type; "[LOW_PRIORITY] WRITE" or "READ [LOCAL]"
11731174 *
11741175 * @return mixed result of the query
11751176 */
1176- public function lockTables (string $ db , array $ tables , string $ lockType = 'WRITE ' )
1177+ public function lockTables (DatabaseName $ db , array $ tables , string $ lockType = 'WRITE ' )
11771178 {
11781179 $ locks = [];
11791180 foreach ($ tables as $ table ) {
1180- $ locks [] = Util::backquote ($ db ) . '. '
1181+ $ locks [] = Util::backquote ($ db-> getName () ) . '. '
11811182 . Util::backquote ($ table ) . ' ' . $ lockType ;
11821183 }
11831184
0 commit comments