CodeIgniter Forums
The dbutil backup function is not working as what i expected - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forum-6.html)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forum-17.html)
+--- Thread: The dbutil backup function is not working as what i expected (/thread-71253.html)



The dbutil backup function is not working as what i expected - niyasali64 - 07-23-2018

This is my code:


PHP Code:
$prefs = array(
 
           'tables'        => array(),  
            
'ignore'        => array(),         
            
'format'        => 'zip'             // gzip, zip, txt
 
           'filename'      => $filename.'.sql'      
            
'add_drop'      => TRUE     
            
'add_insert'    => TRUE    
            
'newline'       => "\n"       
        
);

 
       $backup $this->dbutil->backup($prefs);        
        $backup_path 
'backups/db/'       
        $backup_file 
FCPATH$backup_path $filename"." $prefs["format"]; 
 
       $backup_created write_file$backup_file$backup); 

I am writing a backup data to a file , the string are not getting what i expected ;


Example output:

PHP Code:
INSERT INTO `104_activity_history` (`id`, `user_id`, `ip`, `done_by`, `date`, `activity`, `notification_status`, `data`) VALUES 
(916127.0.0.1162018-07-22 15:21:22login0, ); 

This is what i am expecting:

Quote: Wrote:INSERT INTO `104_activity_history` (`id`, `user_id`, `ip`, `done_by`, `date`, `activity`, `notification_status`, `data`) VALUES (9, 16, '127.0.0.1', 16, '2018-07-22 15:21:22', 'login', 0, '');
Look the value, The invertercomma is missing the output.

Sad Sad Sad Sad Sad Sad Sad Sad Sad Sad



RE: The dbutil backup function is not working as what i expected - php_rocs - 07-23-2018

@niyasali64,

Have you tried running your expected query in MySQL workbench to make sure it works properly? Also, are you sure that your input values are formatted correctly?


RE: The dbutil backup function is not working as what i expected - InsiteFX - 07-24-2018

Why would you have a comma for the last one when you have no value after it?

the comma is an sql delimiter.


RE: The dbutil backup function is not working as what i expected - Paradinight - 07-24-2018

(07-23-2018, 06:11 AM)niyasali64 Wrote: This is my code:


PHP Code:
$prefs = array(
 
           'tables'        => array(),  
            
'ignore'        => array(),         
            
'format'        => 'zip'             // gzip, zip, txt
 
           'filename'      => $filename.'.sql'      
            
'add_drop'      => TRUE     
            
'add_insert'    => TRUE    
            
'newline'       => "\n"       
        
);

 
       $backup $this->dbutil->backup($prefs);        
        $backup_path 
'backups/db/'       
        $backup_file 
FCPATH$backup_path $filename"." $prefs["format"]; 
 
       $backup_created write_file$backup_file$backup); 

I am writing a backup data to a file , the string are not getting what i expected ;


Example output:

PHP Code:
INSERT INTO `104_activity_history` (`id`, `user_id`, `ip`, `done_by`, `date`, `activity`, `notification_status`, `data`) VALUES 
(916127.0.0.1162018-07-22 15:21:22login0, ); 

This is what i am expecting:

Quote: Wrote:INSERT INTO `104_activity_history` (`id`, `user_id`, `ip`, `done_by`, `date`, `activity`, `notification_status`, `data`) VALUES (9, 16, '127.0.0.1', 16, '2018-07-22 15:21:22', 'login', 0, '');
Look the value, The invertercomma is missing the output.

Sad Sad Sad Sad Sad Sad Sad Sad Sad Sad

It is a bug. Pls update the codeigniter version to the latest. After the update create a new backup and test it.

See: https://github.com/bcit-ci/CodeIgniter/issues/5276