function index() { $file = fopen('D:\\DAY122015.csv', "r"); $count = 0; while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE) { $count++; if ($count > 1) { $date = explode("-", $emapData[10]); $data = array('acc_ot_incidental' => $emapData[13], 'ovt_flag' => $emapData[14], 'ovt_reason' => $emapData[16], 'ovt_detail_reason' => $emapData[15]); $this->db->where('id_employee', getPersonIdFromNik($emapData[2]))->where('tanggal', $date[0])->where('bulan', getMonthNumber($date[1]))->where('tahun', $emapData[12])->update('kg_kehadirandetil', $data); echo '<pre>'; echo $this->db->last_query(); echo '</pre>'; } } }
$months['Oct'] = "Październik"; $months['Nov'] = "Listopad"; $months['Dec'] = "Grudzień"; return $months[$month_name]; } require 'scraperwiki/simple_html_dom.php'; $html = scraperWiki::scrape("http://www.myspace.com/bregmaband/shows"); $dom = new simple_html_dom(); $dom->load($html); $eventsContainer = $dom->find('ul[class=eventsContainer]', 0); foreach ($eventsContainer->find('li[class=moduleItem]') as $event) { $entryDate = $event->find('div[class=entryDate]', 0); $month = $entryDate->find('span[class=month]', 0); $day = $entryDate->find('span[class=day]', 0); $details = $event->find('div[class=details]', 0); $record = array('date' => $day->plaintext . " " . getMonthNumber($month->plaintext), 'location' => trim(preg_replace('!\\s+!', ' ', $details->find('span[class=fn]', 0)->plaintext))); scraperwiki::save(array('date'), $record); } function getMonthNumber($month_name) { $month_name = trim($month_name); $months = array(); $months['Jan'] = "Styczeń"; $months['Feb'] = "Luty"; $months['Mar'] = "Marzec"; $months['Apr'] = "Kwiecień"; $months['May'] = "Maj"; $months['Jun'] = "Czerwiec"; $months['Jul'] = "Lipiec"; $months['Aug'] = "Sierpień"; $months['Sep'] = "Wrzesień";
<?php include "sql.php"; if ($_POST['idZapisi'] == 0) { $query = "INSERT INTO zapisi (idZapisi) VALUES (NULL)"; $stats = $db->prepare($query); $stats->execute(); $_POST['idZapisi'] = $db->lastInsertId(); } $qr = "UPDATE zapisi SET Leto=STR_TO_DATE('1. " . getMonthNumber($_POST['mesec']) . " " . $_POST['leto'] . "', '%e. %m %Y'), Razdalja=" . fltdb($_POST['razdalja']) . ", Cas='" . $_POST['ura'] . ":" . $_POST['minuta'] . ":" . $_POST['sekunda'] . "', PovpHitrost=" . fltdb($_POST['povpHitrost']) . ", MaxHitrost=" . fltdb($_POST['maxHitrost']) . ", MinTemp=" . fltdb($_POST['minTemp']) . ", MaxTemp=" . $_POST['maxTemp'] . ", Kalorije=" . $_POST['energija'] . " WHERE idZapisi=" . $_POST['idZapisi']; $q = $db->query($qr); print_r($db->errorInfo());
$aankomstmaand = trim(strip_tags($_POST["aankomst-maand"]), " \n"); $aankomstjaar = trim(strip_tags($_POST["aankomst-jaar"]), " \n"); $aankomstuur = trim(strip_tags($_POST["aankomst-uur"]), " \n"); $aankomstminuut = trim(strip_tags($_POST["aankomst-minuut"]), " \n"); $vertrekdag = trim(strip_tags($_POST["vertrek-dag"]), " \n"); $vertrekmaand = trim(strip_tags($_POST["vertrek-maand"]), " \n"); $vertrekjaar = trim(strip_tags($_POST["vertrek-jaar"]), " \n"); $vertrekuur = trim(strip_tags($_POST["vertrek-uur"]), " \n"); $vertrekminuut = trim(strip_tags($_POST["vertrek-minuut"]), " \n"); // First check if dates are ok and valid, if so build the proper string $startSTR = ""; $endSTR = ""; $alreadyReserved = False; //Convert the month name to month number $aankomstmaandNummer = getMonthNumber($aankomstmaand); $vertrekmaandNummer = getMonthNumber($vertrekmaand); if ($aankomstmaandNummer === -1 || $vertrekmaandNummer === -1) { incompleteData("aankomsts- en/of vertrekmaand"); } if (!validDate($aankomstjaar, $aankomstmaandNummer, $aankomstdag, $aankomstuur, $aankomstminuut) || !validDate($vertrekjaar, $vertrekmaandNummer, $vertrekdag, $vertrekuur, $vertrekminuut)) { //Wrong dates, so indicate that incompleteData("aankomst- en/of vertrekdatum"); } //Dates valid, so create the actual string $start = new DateTime(); $start->setDate($aankomstjaar, $aankomstmaandNummer, $aankomstdag); $start->setTime($aankomstuur, $aankomstminuut); $startSTR = $start->format(DATE_TIME_FORMAT); $end = new DateTime(); $end->setDate($vertrekjaar, $vertrekmaandNummer, $vertrekdag); $end->setTime($vertrekuur, $vertrekminuut);