コード例 #1
0
 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;
 }