0

I need to backup a database table but with a where condition on few of the columns. I have lookup up about the dbutil utility in codeigniter but there is no option of applying a where condition on the table.

$prefs = array(
    'tables'        => array('table1', 'table2'),   // Array of tables to backup.
    'ignore'        => array(),                     // List of tables to omit from the backup
    'format'        => 'txt',                       // gzip, zip, txt
    'filename'      => 'mybackup.sql',              // File name - NEEDED ONLY WITH ZIP FILES
    'add_drop'      => TRUE,                        // Whether to add DROP TABLE statements to backup file
    'add_insert'    => TRUE,                        // Whether to add INSERT data to backup file
    'newline'       => "\n"                         // Newline character used in backup file
);

As per the codeigniter documentation, there is no mention of where condition on table(s).

  • From what I see in the code, no. https://github.com/bcit-ci/CodeIgniter/blob/develop/system/database/DB_utility.php – kchason Nov 30 '17 at 12:32
  • There's [the `mysqldump` utility that takes a `where` argument.](https://stackoverflow.com/a/26261717/3585500) You can [`exec()` from php.](https://stackoverflow.com/a/18372425/3585500) – ourmandave Nov 30 '17 at 13:02

0 Answers0