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