从xml插入数据库多行,没有错误

时间:2015-12-10 12:54:08

标签: mysql xml insert

我有一种情况,我不知道为什么下面的代码只在数据库中插入一行,尽管我从xml文件中获得了4000多行。我不明白插入查询似乎有问题。任何帮助表示赞赏。

foreach($produse as $key => $val) {
        echo $val['cod'] . ' - ' . $val['producator'] . '<br/>';  

        mysqli_query($con, "
                        INSERT INTO 
                            aa_produse_royal 
                        (
                            activ, 
                            stoc,
                            cod,
                            denumire,
                            grupa,
                            producator,
                            descriere,
                            valuta,
                            pret,
                            pret_lei,
                            data_adaugare,
                            link_producator,
                            poze,
                            poze_noi
                        ) 
                        VALUES 
                        (
                            1,
                            '" . $val['stoc'] . "',
                            '" . $val['cod'] . "',
                            '" . $val['denumire'] . "',
                            '" . $val['grupa'] . "',
                            '" . $val['producator'] . "',
                            '" . $val['descriere'] . "',
                            '" . $val['valuta'] . "',
                            '" . $val['pret_lista'] . "',
                            '" . $val['pret'] . "',
                            CURDATE(),
                            '" . $val['link'] . "',
                            '" . $val['imagini'] . "',
                            1
                        ) 
                        ON DUPLICATE KEY UPDATE 
                        activ=VALUES(activ),
                        stoc=VALUES(stoc),
                        valuta=VALUES(valuta),
                        pret=VALUES(pret),
                        pret_lei=VALUES(pret_lei),
                        data_modificare=CURDATE()
                    ") or die(mysqli_error($con));
        //echo $val['cod']."<br>";
    }
echo "S-au introdus in baza de date  " . mysqli_affected_rows($con) . " randuri"; 

0 个答案:

没有答案