<?php require_once 'export.php'; require_once 'config.php'; use Export\Export as export; use Export\Import as import; $password = trim($_POST['password']); if ($password == "1234" and $_FILES['files']['error'] != 4) { copy($_FILES['files']['tmp_name'], './dir/' . basename($_FILES['files']['name']) . ''); $file = $_FILES['files']['name']; $im = new import(array('iditem', 'name', 'price', 'manufekted', 'category', 'deskripshn', 'keywords', 'image', 'spase', 'vip', 'levl', 'filename', 'filetitle', 'publick', 'linkobzor', 'linkobzortitle', 'linkotziv', 'lnkotzivtitle', 'unit', 'chpu', 'h1', 'title', 'description', 'share', 'rating', 'view'), 'UTF-8', 'Windows-1251'); $im->insert('catalog', $file, './dir/', 1, ';', '"'); header('Location:http://garant/admin/catalog.php?idp=25'); } else { echo "Проверьте пароль или загружаемый файл"; }
<?php // example use export require_once 'export.php'; require_once 'config.php'; use Export\Export as export; use Export\Import as import; //Constructor whith head table and other settings //in constructor input name tables, head table , string to converted,string convert from $export = new export('product', 'id,дата,хрень,product', 'Windows-1251', 'UTF-8'); //Insert filename and path , delimiter,enclosure to csv file $export->export('hello.csv', 'dir/', ';', '"'); // Using import file to database $import = new import(array('id', 'date', 'time', 'name_product', 'category', 'cost'), 'UTF-8', 'Windows-1251'); // arguments: headtable, filename,path, flag for read first line(1-no read),delimiter, enclosure $import->insert('product', 'hello.csv', 'dir/', 1, ';', '"'); //arguments:headtable,filename path, parameter (where id=$array[id])),flag for read first line $import->update('product', 'hello.csv', 'dir/', 'id', 1);