span style="color: #0000BB"><?php $insert = "INSERT INTO `$this->_INFO_TABLE_NAME` " . "(`id`, `title`, `description`, `duration`, `img`, `errno`, `expire`, `data`)\n"; $values = []; foreach ($arrayData as $data) { $id = "'{$data['id']}'"; $title = "'" .$this->_mysqli->real_escape_string($data['title']) . "'"; $description = "'" . $this->_mysqli->real_escape_string($data['description']) . "'"; $duration = $data['duration']; $img = "'" . $data['img'] . "'"; $errno = (int)$data['errno']; $otherData = $data['data'] ? "'".$this->_mysqli->real_escape_string(serialize($data['data']))."'" : "''"; $values[] = "($id, $title, $description, $duration, $img, $errno, {$_SERVER['REQUEST_TIME']}, $otherData)"; } $insert .= 'VALUES '. implode (",\n", $values) . "\n" . "ON DUPLICATE KEY UPDATE\n" . "`title` = COALESCE(NULLIF(title, ''), VALUES(title)),\n" . "`description` = COALESCE(NULLIF(description, ''), VALUES(description)),\n" . "`img` = COALESCE(NULLIF(img, ''), VALUES(img)),\n" . "`errno` = VALUES(errno),\n" . "`expire` = VALUES(expire),\n" . "`data`= COALESCE(NULLIF(data, ''), VALUES(data))\n"; $result = $this->_mysqli->query($insert); var_dump($result); var_dump($this->_mysqli->error); echo $insert; |