@@ -553,6 +553,7 @@ class SQL_Backup extends FILES {
553553 public $ del_csv ;
554554 public $ enc_csv ;
555555 public $ sql_unique ;
556+ public $ down ;
556557 public $ json_options ;
557558 public $ res = false ;
558559
@@ -568,10 +569,10 @@ class SQL_Backup extends FILES {
568569 * @var bool $phpmyadmin ...
569570 * @var bool $save Output saved in a file or outputed as string
570571 * @var bool $sql_unique Output (sql) unified in a unique file/query
571- * @var bool $download Output automatic downloaded (SOON)
572+ * @var bool $down Output automatic downloaded
572573 **/
573574
574- function __construct ($ con = null , $ table_name = null , $ ext = null , $ fname = null , $ folder = null , $ query_limit = null , $ archive = null , $ phpmyadmin = null , $ save = null , $ sql_unique = null ) {
575+ function __construct ($ con = null , $ table_name = null , $ ext = null , $ fname = null , $ folder = null , $ query_limit = null , $ archive = null , $ phpmyadmin = null , $ save = null , $ sql_unique = null , $ down = null ) {
575576 parent ::__construct ();
576577 $ this ->con = $ con ;
577578 $ this ->table_name = $ table_name ;
@@ -582,6 +583,7 @@ function __construct($con = null, $table_name = null, $ext = null, $fname = null
582583 $ this ->ext = $ ext ;
583584 $ this ->phpmyadmin = $ phpmyadmin ;
584585 $ this ->save = $ save ;
586+ $ this ->down = $ down ;
585587 $ this ->sql_unique = $ sql_unique ;
586588 }
587589
@@ -599,48 +601,37 @@ public function execute($debug = false) {
599601 if ($ this ->check ($ this ->folder , "folder " ) == false )
600602 return $ debug === true ? $ this ->debug () : false ;
601603 $ tables = $ this ->check ($ this ->table_name , "tables " );
604+ $ name_temp = "temp_backup " . md5 (microtime (true ) . mt_rand ());
602605 foreach ($ this ->ext as $ type_ext ) {
603606 $ type_ext = trim ($ type_ext );
604- if ($ this ->save == false ) {
607+ if ($ this ->save == false || $ this -> down == true ) {
605608 $ res_x = false ;
606609 $ create = $ this ->create ($ type_ext , $ tables );
607- if ($ this ->last_err_db == null )
608- $ res [$ type_ext ] = $ create ;
610+ if ($ this ->last_err_db == null ) {
611+ if ($ this ->save == false )
612+ $ res [$ type_ext ] = $ create ;
613+ if ($ this ->down == true ) {
614+ $ n = 1 ;
615+ foreach ($ create as $ table => $ tb ) {
616+ $ this ->_save ($ tb , "TB " . $ n . "_Name[ " . $ table . "]_Date[ " . date ("d-m-Y-H-i-s " ) . "]_Crc32b[ " . hash ("crc32b " , $ tb ) . "]. " . $ type_ext , $ name_temp , $ type_ext , 'zip ' );
617+ ++$ n ;
618+ }
619+ }
620+ }
609621 } else {
610622 if (!$ this ->save ($ type_ext , $ tables , $ this ->folder . '/ ' . $ this ->fname ))
611623 $ res_x = false ;
612624 }
613625 }
614626 $ this ->res = $ res = empty ($ res ) ? $ res_x : $ res ;
627+ if ($ this ->down == true )
628+ return $ this ->DownloadFile ($ name_temp . '.zip ' , true , "Backup_MYSQL( " . date ("Y-m-d-H-i-s " ) . ").zip " );
615629 if ($ debug === true )
616630 return $ this ->debug ();
617631 $ this ->clean_var ();
618632 return $ res ;
619633 }
620634
621- public function execute_down () {
622- $ this ->checking ();
623- if ($ this ->check ($ this ->con , "con " ) == false )
624- return false ;
625- if ($ this ->check ($ this ->folder , "folder " ) == false )
626- return false ;
627- $ tables = $ this ->check ($ this ->table_name , "tables " );
628- $ name_temp = "temp_backup " . md5 (microtime (true ) . mt_rand ());
629- foreach ($ this ->ext as $ type_ext ) {
630- $ type_ext = trim ($ type_ext );
631- $ create = $ this ->create ($ type_ext , $ tables );
632- if ($ this ->last_err_db == null ) {
633- $ n = 1 ;
634- foreach ($ create as $ table => $ tb ) {
635- $ this ->_save ($ tb , "TB " . $ n . "_Name[ " . $ table . "]_Date[ " . date ("d-m-Y-H-i-s " ) . "]_Crc32b[ " . hash ("crc32b " , $ tb ) . "]. " . $ type_ext , $ name_temp , $ type_ext , 'zip ' );
636- ++$ n ;
637- }
638- }
639- }
640- $ this ->clean_var ();
641- return $ this ->DownloadFile ($ name_temp . '.zip ' , true , "Backup_MYSQL( " . date ("Y-m-d-H-i-s " ) . ").zip " );
642- }
643-
644635 private function checking () {
645636 $ this ->check ($ this ->ext , "ext " );
646637 $ this ->check ($ this ->save , "save " );
@@ -949,6 +940,7 @@ private function clean_var() {
949940 unset($ this ->name_file );
950941 unset($ this ->path_file );
951942 unset($ this ->last_err_db );
943+ unset($ this ->down );
952944 }
953945
954946 private function debug () {
0 commit comments