Ejemplo n.º 1
0
<?php

namespace export;

require 'medoo.min.php';
require 'config.php';
use medoo;
use PDO;
Export::$config = $config;
Import::$config = $config;
class Export
{
    protected $table_head;
    protected $arr;
    protected $to_encoding;
    protected $from_encoding;
    protected $table_name;
    public static $config;
    function __construct($table_name, $x = '', $delimiter = ',', $to_encoding = 'UTF-8', $from_encoding = 'UTF-8')
    {
        //формируем шапку для сохраняемой таблицы,где x--  текст шапки
        //create head for table, where $x -- string whith head table
        $x = mb_convert_encoding($x, $to_encoding, $from_encoding);
        $this->arr = explode($delimiter, $x);
        $this->to_encoding = $to_encoding;
        $this->from_encoding = $from_encoding;
        $this->table_name = $table_name;
    }
    //connect to db
    private function create_db_connect()
    {
Ejemplo n.º 2
0
<?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 "Проверьте пароль или загружаемый файл";
}
Ejemplo n.º 3
0
<?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);