public function import($table, $fileName) { parent::__construct($fileName); $qwery = " "; $j = 1; for ($i = 1; $i < parent::getNumRows(); $i++) { $qwery = "INSERT INTO `mail_data`(`comp_name`, `email`, `phone`, `adres`, `called`, `sended`, `coments`) \n\t\t\tVALUES ("; while (parent::issetCell($i, $j)) { $item = parent::getCellValue($i, $j); if ($j == 1) { $qwery = $qwery . "'" . $this->mysqli->real_escape_string($item) . "'"; } else { $qwery = $qwery . ",'" . $this->mysqli->real_escape_string($item) . "'"; } $j++; } $qwery = $qwery . ", '0', '0', NULL)"; $result = $this->mysqli->query($qwery); if ($result === false) { echo 'Nie można było wykonać zapytania z powodu błędu: ' . $this->mysqli->error; exit(1); } $j = 1; } return true; }
/** * Constructor */ public function __construct() { parent::__construct(); $this->setSeparator("\t"); }
/** * @param string $file * @param \Magento\Framework\Filesystem\Directory\Write $directory * @param string $options */ public function __construct($file, \Magento\Framework\Filesystem\Directory\Write $directory, $options) { $zip = new \Magento\Framework\Archive\Zip(); $file = $zip->unpack($directory->getRelativePath($file), $directory->getRelativePath(preg_replace('/\\.zip$/i', '.csv', $file))); parent::__construct($file, $directory, $options); }