@@ -256,6 +256,10 @@ protected function csv_mysqli($con, $table, $del, $enc, $header_name) {
256256
257257 $ num_fields = $ result ->field_count ;
258258
259+ if (!is_string ($ del ) || strlen ($ del ) != 1 )
260+ $ del = ", " ;
261+ if (!is_string ($ enc ) || strlen ($ enc ) != 1 )
262+ $ enc = "" ;
259263
260264 /* HEADER */
261265
@@ -654,22 +658,13 @@ protected function create($ext, $tables) {
654658 foreach ($ tables as $ table ) {
655659 switch ($ ext ) {
656660 case "sql " :
657- $ option = 400 ;
658- if (is_int ($ this ->qlimit ))
659- $ option = $ this ->qlimit ;
660- $ res [$ table ] = $ this ->query_sql ($ table , $ option );
661+ $ res [$ table ] = $ this ->query_sql ($ table , $ this ->qlimit );
661662 break ;
662663 case "csv " :
663- $ option = true ;
664- if ($ this ->header_name === true || $ this ->header_name === false )
665- $ option = $ this ->header_name ;
666- $ res [$ table ] = $ this ->query_csv ($ table , $ option );
664+ $ res [$ table ] = $ this ->query_csv ($ table , $ this ->header_name );
667665 break ;
668666 case "json " :
669- $ option = 0 ;
670- if (is_int ($ this ->json_options ))
671- $ option = $ this ->json_options ;
672- $ res [$ table ] = $ this ->query_json ($ table , $ option );
667+ $ res [$ table ] = $ this ->query_json ($ table , $ this ->json_options );
673668 break ;
674669 }
675670 }
@@ -684,13 +679,10 @@ protected function save($ext, $tables, $filename) {
684679 foreach ($ tables as $ table ) {
685680 switch ($ ext ) {
686681 case "sql " :
687- $ option = 400 ;
688- if (is_int ($ this ->qlimit ))
689- $ option = $ this ->qlimit ;
690682 if ($ this ->sql_unique == true ) {
691- $ tb .= $ this ->query_sql ($ table , $ option );
683+ $ tb .= $ this ->query_sql ($ table , $ this -> qlimit );
692684 } else {
693- $ tb = $ this ->query_sql ($ table , $ option );
685+ $ tb = $ this ->query_sql ($ table , $ this -> qlimit );
694686 $ this ->name_file [] = $ name = "TB " . $ n . "_Name[ " . $ table . "]_Date[ " . date ("d-m-Y-H-i-s " ) . "]_Crc32b[ " . hash ("crc32b " , $ tb ) . "].sql " ;
695687 if ($ this ->phpmyadmin == false ) {
696688 if ($ this ->_save ($ tb , $ name , $ filename , 'sql ' , $ comp ) == false )
@@ -699,14 +691,10 @@ protected function save($ext, $tables, $filename) {
699691 if ($ this ->_save ($ tb , $ name , $ filename . '- ' . $ table . '- ' . hash ('crc32b ' , microtime (true ) . mt_rand ()) . ".sql " , '' , "zip " ) == false )
700692 ++$ e ;
701693 }
702-
703694 }
704695 break ;
705696 case "csv " :
706- $ option = true ;
707- if ($ this ->header_name === true || $ this ->header_name === false )
708- $ option = $ this ->header_name ;
709- $ tb = $ this ->query_csv ($ table , $ option );
697+ $ tb = $ this ->query_csv ($ table , $ this ->header_name );
710698 $ this ->name_file [] = $ name = "TB " . $ n . "_Name[ " . $ table . "]_Date[ " . date ("d-m-Y-H-i-s " ) . "]_Crc32b[ " . hash ("crc32b " , $ tb ) . "].csv " ;
711699 if ($ this ->phpmyadmin == false ) {
712700 if ($ this ->_save ($ tb , $ name , $ filename , 'csv ' , $ comp ) == false )
@@ -717,11 +705,8 @@ protected function save($ext, $tables, $filename) {
717705 }
718706 break ;
719707 case "json " :
720- $ option = 0 ;
721- if (is_int ($ this ->json_options ))
722- $ option = $ this ->json_options ;
723708 if ($ this ->phpmyadmin == false ) {
724- $ tb = $ this ->query_json ($ table , $ option );
709+ $ tb = $ this ->query_json ($ table , $ this -> json_options );
725710 $ this ->name_file [] = $ name = "TB " . $ n . "_Name[ " . $ table . "]_Date[ " . date ("d-m-Y-H-i-s " ) . "]_Crc32b[ " . hash ("crc32b " , $ tb ) . "].json " ;
726711 if ($ this ->_save ($ tb , $ name , $ filename , 'json ' , $ comp ) == false )
727712 ++$ e ;
@@ -802,18 +787,10 @@ protected function query_sql($table, $limit) {
802787 }
803788
804789 protected function query_csv ($ table , $ header_name ) {
805- $ del = ', ' ;
806- $ enc = '' ;
807- if ($ header_name !== true && $ header_name !== false )
808- $ header_name = true ;
809- if ($ this ->del_csv != null )
810- $ del = $ this ->del_csv ;
811- if ($ this ->enc_csv != null )
812- $ enc = $ this ->enc_csv ;
813790 if ($ this ->type == "mysqli " )
814- return $ this ->csv_mysqli ($ this ->con , $ table , $ del , $ enc , $ header_name );
791+ return $ this ->csv_mysqli ($ this ->con , $ table , $ this -> del_csv , $ this -> enc_csv , $ header_name );
815792 if ($ this ->type == "PDO " )
816- return $ this ->csv_pdo ($ this ->con , $ table , $ del , $ enc , $ header_name );
793+ return $ this ->csv_pdo ($ this ->con , $ table , $ this -> del_csv , $ this -> enc_csv , $ header_name );
817794 return false ;
818795 }
819796
@@ -960,4 +937,4 @@ private function debug() {
960937}
961938
962939
963- ?>
940+ ?>
0 commit comments