Codeignitier shows me just "loaded" from echo, but table is empty when i try to execute this using PDO:
function loadCSVtoDB($csvfile){
$stmt = $this->db->conn_id->prepare("LOAD DATA LOCAL INFILE :file
INTO TABLE `historic` FIELDS TERMINATED BY ',' LINES TERMINATED BY '
'");
$stmt->bindParam(":file",$csvfile);
$stmt->execute();
echo 'loaded';
//echo $this->db->conn_id->error_message();
}
My database config is:
$db['default'] = array(
'dsn' => '',
'hostname' => 'mysql:host=localhost',
'username' => 'zzazfhvsnt',
'password' => 'censored',
'database' => 'zzazfhvsnt',
'dbdriver' => 'pdo',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
When i remove conn_id, i get
Fatal error: Call to undefined method CI_DB_pdo_mysql_driver::prepare()
Same is when i change exec instead prepare.
I call it like this from constructor:
$this->load->model('Historic_model');
$this->Historic_model->loadCSVtoDB("assets/csv/1516E0.csv");
In autoload is: $autoload['libraries'] = array('database');