Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $filepath = $this->storage_path . 'marketing_opt_out.csv';
- $status = Subscribers::STATUS_READY_TO_IMPORT;
- $importInto = Subscribers::IMPORT_INTO_DM;
- $lookupStmt = $mysqli->prepare("SELECT id FROM orderwise_subscribers WHERE orderwise_id = ?");
- $insertStmt = $mysqli->prepare("INSERT INTO orderwise_subscribers (
- orderwise_id, subscribed, email, status, import_into
- ) VALUES (
- ?, 0, ?, 1, 1)");
- if($fp = fopen($filepath, "r")) {
- $y = 1000;
- while ($csvLine = fgetcsv($fp)) {
- $lookupStmt->bind_param('s', $csvLine[1]);
- $lookupStmt->execute();
- $result = $lookupStmt->get_result();
- // // No record exists
- if($result->num_rows === 0) {
- $insertStmt->bind_param('ss', $csvLine[1], $csvLine[0]);
- $insertStmt->execute();
- }
- if($y % 1000 == 0) {
- echo "<pre>", print_r('memory usage : ' . memory_get_usage()), "</pre>";
- }
- $y++;
- }
- fclose($fp);
- }
- $lookupStmt->close();
- $insertStmt->close();
- $mysqli->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement