Skip to content

Instantly share code, notes, and snippets.

@jbrooksuk jbrooksuk/slow.php
Created Apr 4, 2014

Embed
What would you like to do?
<?php
private function loadQuotes() {
$this->comment('Loading quotes...');
$hFile = fopen($this->store . 'quotes.csv', 'r');
$progress = $this->getHelperSet()->get('progress');
$progress->setFormat($progress::FORMAT_VERBOSE_NOMAX);
$progress->start($this->getOutput());
$progress->setRedrawFrequency(100);
// Start by TRUNCATEing the table.
\DB::statement("TRUNCATE quote");
$progress->advance();
$QuoteRow = 0;
while(($QuoteData = fgetcsv($hFile, 0, ',', '"')) !== FALSE) {
if($QuoteRow > 0) {
$Quote = new \Quote;
$Quote->qid = $QuoteData[0];
$Quote->uid = $QuoteData[1];
$Quote->added_by = $QuoteData[2];
$Quote->status = $QuoteData[5];
$Quote->agent_id = $QuoteData[6];
$Quote->date_tagged = $QuoteData[7];
$Quote->date_completed = $QuoteData[8] . ' ' . $QuoteData[34];
$Quote->date_booked = $QuoteData[9] . ' ' . $QuoteData[38];
if(!is_null($QuoteData[11]) && $QuoteData[11] !== 'NULL') $Quote->country = $QuoteData[11];
if(!is_null($QuoteData[12]) && $QuoteData[12] !== 'NULL') $Quote->hotel = $QuoteData[12];
$Quote->hotel_id = $QuoteData[13];
if(!is_null($QuoteData[14]) && $QuoteData[14] !== 'NULL') $Quote->iso = $QuoteData[14];
$Quote->depart_1 = $QuoteData[15];
$Quote->depart_2 = $QuoteData[16];
$Quote->duration = $QuoteData[17];
$Quote->adults = $QuoteData[18];
$Quote->children = $QuoteData[19];
$Quote->no_rooms = $QuoteData[21];
$Quote->room_type = $QuoteData[22];
$Quote->airport = $QuoteData[23];
$Quote->budget = $QuoteData[24];
$Quote->comp_name = $QuoteData[25];
$Quote->comp_price = $QuoteData[26];
$Quote->prev_cust = $QuoteData[27];
$Quote->callback = $QuoteData[28];
$Quote->occasion = $QuoteData[29];
$Quote->comments = $QuoteData[30];
$Quote->priority = $QuoteData[31];
$Quote->promising = $QuoteData[32];
$Quote->c_source = $QuoteData[33];
if(!is_null($QuoteData[35]) && $QuoteData[35] !== "NULL") $Quote->first_tagged = $QuoteData[35];
if(!is_null($QuoteData[40]) && $QuoteData[40] !== 'NULL') $Quote->offer_code = $QuoteData[40];
if(!is_null($QuoteData[42]) && $QuoteData[42] !== 'NULL') $Quote->agency = $QuoteData[42];
if(!is_null($QuoteData[43]) && $QuoteData[43] !== 'NULL') $Quote->agency_alias = $QuoteData[43];
if(!is_null($QuoteData[44]) && $QuoteData[44] !== 'NULL') $Quote->agency_code = $QuoteData[44];
if(!is_null($QuoteData[41]) && $QuoteData[41] !== 'NULL') $Quote->time_slot = $QuoteData[41];
$Quote->trashed = 0;
$Quote->created_at = $QuoteData[3] . ' ' . $QuoteData[4];
$Quote->updated_at = $Quote[10];
$Quote->save();
unset($Quote);
}else{
$QuoteRow++;
}
$progress->advance();
}
$progress->finish();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.