2016-07-26 122 views
2

如何使用代碼點火器將數組數據插入到mysql? 我試過例如,從這樣的向mysql codeigniter插入數組數據3

$data = array(
     'id_kls' => 'id_kls', 
     'fk__id_kls' => 'fk__id_kls', 
     'id_reg_pd' => 'id_reg_pd', 
     'nm_pd' => 'nm_pd', 
     'asal_data' => 'asal_data', 
     'nilai_angka' => 'nilai_angka', 
     'nilai_huruf' => 'nilai_huruf', 
     'nilai_indeks' => 'nilai_indeks',  
); 
$this->db->insert('master_nilai', $data); 

    // Executes: REPLACE INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date') 

但不工作CI文檔..

我有這樣

Array 
(
    [error_code] => 0 
    [error_desc] => 
    [result] => Array 
     (
      [0] => Array 
       (
        [id_kls] => f77294f7-2a5a-4876-860b-824d227d5b19 
        [fk__id_kls] => 02 
        [id_reg_pd] => 001be76b-4e58-4cea-96cf-fee2d8e0abdc 
        [nm_pd] => SUYATNO 
        [asal_data] => 9 
        [nilai_angka] => 
        [nilai_huruf] => B 
        [nilai_indeks] => 3.00 
       ) 
+0

您可以使用'insert_batch('table_name',$ your_data)' –

回答

-1

陣列數據確保您已啓用的config/autoload.php/$ autoload ['libraries'] = array('database'); 和config/database.php /你的主機名,用戶名,dbname!