php - Codigniter backup library creating wrong insert query -
i creating backup using codigniter library "dbutil" , have fields in mysql database having datatype bit when using below given code
public function run_backup() { $filename="memberspro_database_$this->curr_date.sql"; $filepath="application/upload/databasebackup/$filename"; $dbfilepath="memberspro/application/upload/databasebackup/$filename"; $prefs = array( 'ignore' => array(), // list of tables omit backup 'format' => 'sql', // gzip, zip, txt 'filename' =>$filepath, // file name - needed zip files 'add_drop' => true, // whether add drop table statements backup file 'add_insert' => true, "foreign_key_checks" =>false /* 'newline' => "\n",*/ // newline character used in backup file ); $backup="create database if not exists `membersmanagmentsystem`; use `membersmanagmentsystem` "; $backup .= $this->dbutil->backup($prefs); if(!write_file($filepath, $backup)) { echo "error";die; } else { $_session['sucessmsgbackup']="true"; } $this->insert_into_datbase($filename,$dbfilepath); redirect("viewdatabasebackup"); } getting wrong output insert query
insert `user` (`userid`, `userroleid`,`useractive`, `userisdelete`) values ('20000046', '20001','1', '0'); in above given query "useractive" , "userisdelete" fields having datatype "bit" , query create dbutil library treating string getting warning error in mysql
"out of range column value"
read here why should not use bit columns in mysql
look folder , modify core classes it not escape, example mysqli driver
system/database/drivers/mysqli
and find file mysqli_utility.php
locate line
$is_int[$i] = in_array(strtolower($field->type), array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'), true); type numbers
numerics ------------- bit: 16 tinyint: 1 bool: 1 smallint: 2 mediumint: 9 integer: 3 bigint: 8 serial: 8 float: 4 double: 5 decimal: 246 numeric: 246 fixed: 246 and add datatype above array below
$is_int[$i] = in_array($field->type, array(16, 1, 2, 9, 3, 8), true);
Comments
Post a Comment