Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dsn = 'mysql:dbname=phpshop;host=localhost';
- $user = 'root';
- $password = '';
- echo time();
- try {
- $db = new PDO($dsn, $user, $password,
- array(PDO::ATTR_PERSISTENT => true));
- $db->exec("set names utf8");
- echo "Podkluchilis\n";
- }
- catch (Exception $e) {
- die("Ne udalos podkluchitja: " . $e->getMessage());
- }
- $items = simplexml_load_file("edosha.xml");
- $kolvo = 0;
- foreach ($items->Item as $item) {
- $code = '';
- $parentcode = '';
- $name = '';
- $descr = '';
- $article = '';
- $typeprice = '';
- $price = '';
- $currency = '';
- $remains = '';
- $unit = '';
- $code = $item->Code;
- $parentcode = $item->ParentCode;
- $name = $item->Name;
- $descr = $item->Descr;
- $article = $item->Article;
- $typeprice = $item->TypePrice;
- $price = $item->Price;
- $currency = $item->Currency;
- $remains = $item->Remains;
- $unit = $item->Unit;
- try {
- $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $db->beginTransaction();
- $db->exec("INSERT INTO product_1c (code, parentcode, name, descr, article, typeprice, price, currency, remains, unit ) values ('$code', '$parentcode', '$name' , '$descr', '$article', '$typeprice', '$price' , '$currency', '$remains', '$unit')");
- $db->commit();
- $kolvo=$kolvo+1;
- }
- catch (Exception $e) {
- $db->rollBack();
- echo "Ошибка: " . $e->getMessage();
- }
- }
- echo "Kolichestvo zapisey = ".$kolvo;
- echo time();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement