public function updateCar($car) { $Id = $car->getId(); $SiteId = toNull($car->getSiteId(), false); $CarBrandId = toNull($car->getCarBrandId(), false); $Type = toNull(escape($car->getType()), true); $TypeShort = toNull(escape($car->getTypeShort()), true); $PreviewLink = toNull(escape($car->getPreviewLink()), true); $DateAdded = toNull(toYYYYMMDD($car->getDateAdded()), true); $State = toNull(escape($car->getState()), true); $DateApproved = toNull(toYYYYMMDD($car->getDateApproved()), true); $FolderName = toNull(escape($car->getFolderName()), true); $PressContactId = toNull($car->getPressContactId(), false); $UserIdAdded = toNull($car->getUserIdAdded(), false); $UserIdApproved = toNull($car->getUserIdApproved(), false); $DetailTypeId = toNull($car->getDetailTypeId(), false); $DefaultPictureId = toNull($car->getDefaultPictureId(), false); $LRClicks = toNull($car->getLRClicks(), false); $HRClicks = toNull($car->getHRClicks(), false); $Views = toNull($car->getViews(), false); $ReleaseDate = toNull(escape($car->getReleaseDate()), true); $MovieFolder = toNull(escape($car->getMovieFolder()), true); $sql = "UPDATE car\n\t\t\tSET SiteId = {$SiteId},\n\t\t\tCarBrandId = {$CarBrandId},\n\t\t\tType = {$Type},\n\t\t\tTypeShort = {$TypeShort},\n\t\t\tPreviewLink = {$PreviewLink},\n\t\t\tDateAdded = {$DateAdded},\n\t\t\tState = {$State},\n\t\t\tDateApproved = {$DateApproved},\n\t\t\tFolderName = {$FolderName},\n\t\t\tPressContactId = {$PressContactId},\n\t\t\tUserIdAdded = {$UserIdAdded},\n\t\t\tUserIdApproved = {$UserIdApproved},\n\t\t\tDetailTypeId = {$DetailTypeId},\n\t\t\tDefaultPictureId = {$DefaultPictureId},\n\t\t\tLRClicks = {$LRClicks},\n\t\t\tHRClicks = {$HRClicks},\n\t\t\tViews = {$Views},\n\t\t\tReleaseDate = {$ReleaseDate},\n MovieFolder = {$MovieFolder}\n\t\t\tWHERE Id = {$Id}"; if (!mysql_query($sql, $this->connectie)) { die('Error: ' . mysql_error()); } }
public function getUserByUserNameExcludeId($account, $id) { $account = toNull(escape($account), true); $sql = "SELECT * FROM user WHERE account={$account} && id != {$id}"; $resultaat = mysql_query($sql, $this->connectie); return mysql_num_rows($resultaat); }
public function updateDetailType($detailType) { $Id = $detailType->getId(); $OnlyLink = toNull($detailType->getOnlyLink(), false); $sql = "UPDATE detailtype\n\t\t\tSET OnlyLink = {$OnlyLink}\n\t\t\tWHERE Id = {$Id}"; if (!mysql_query($sql, $this->connectie)) { die('Error: ' . mysql_error()); } }
public function updateMovieType($movieType) { $Id = $movieType->getId(); $Name = toNull(escape($movieType->getName()), true); $Text = toNull(escape($movieType->getText()), true); $sql = "UPDATE movietype\n\t\t\tSET Name = {$Name},\n\t\t\tText = {$Text}\n\t\t\tWHERE Id = {$Id}"; if (!mysql_query($sql, $this->connectie)) { die('Error: ' . mysql_error()); } }
public function updateBlobs($blobs) { $Id = $blobs->getId(); $BlobData = toNull($blobs->getBlobData()); $FileSize = toNull($blobs->getFileSize(), false); $sql = "UPDATE blobs\n\t\t\tSET BlobData = {$BlobData},\n FileSize = {$FileSize}\n\t\t\tWHERE Id = {$Id}"; if (!mysql_query($sql, $this->connectie)) { die('Error: ' . mysql_error()); } }
public function updateCarLink($carLink) { $Id = $carLink->getId(); $Text = toNull(escape($carLink->getText()), true); $URL = toNull(escape($carLink->getURL()), true); $CarId = toNull($carLink->getCarId(), false); $sql = "UPDATE carlink\n\t\t\tSET Text = {$Text},\n\t\t\tURL = {$URL},\n\t\t\tCarId = {$CarId}\n\t\t\tWHERE Id = {$Id}"; if (!mysql_query($sql, $this->connectie)) { die('Error: ' . mysql_error()); } }
public function updatePictureOrder($pictureOrder) { $Id = $pictureOrder->getId(); $Nr = toNull($pictureOrder->getNr(), false); $CarId = toNull($pictureOrder->getCarId(), false); $CarPictureId = toNull($pictureOrder->getCarPictureId(), false); $sql = "UPDATE pictureorder\n\t\t\tSET Nr = {$Nr},\n\t\t\tCarId = {$CarId},\n\t\t\tCarPictureId = {$CarPictureId}\n\t\t\tWHERE Id = {$Id}"; if (!mysql_query($sql, $this->connectie)) { die('Error: ' . mysql_error()); } }
public function updateCarBrand($carBrand) { $Id = $carBrand->getId(); $Name = toNull(escape($carBrand->getName()), true); $Logo = toNull($carBrand->getLogo(), false); $MovieFolder = toNull(escape($carBrand->getMovieFolder()), true); $sql = "UPDATE carbrand\n\t\t\tSET Name = {$Name},\n\t\t\tLogo = {$Logo},\n\t\t\tMovieFolder = {$MovieFolder}\n\t\t\tWHERE Id = {$Id}"; if (!mysql_query($sql, $this->connectie)) { die('Error: ' . mysql_error()); } }
public function updatePressContact($pressContact) { $Id = $pressContact->getId(); $Name = toNull(escape($pressContact->getName()), true); $HTMLContent = toNull(escape($pressContact->getHTMLContent()), true); $CarBrandId = toNull($pressContact->getCarBrandId(), false); $sql = "UPDATE presscontact\n\t\t\tSET Name = {$Name},\n\t\t\tHTMLContent = {$HTMLContent},\n\t\t\tCarBrandId = {$CarBrandId}\n\t\t\tWHERE Id = {$Id}"; if (!mysql_query($sql, $this->connectie)) { die('Error: ' . mysql_error()); } }
public function updateCarPicture($carPicture) { $Id = $carPicture->getId(); $Name = toNull(escape($carPicture->getName()), true); $Type = toNull(escape($carPicture->getType()), true); $CarId = toNull($carPicture->getCarId(), false); $BlobId = toNull($carPicture->getBlobId(), false); $sql = "UPDATE carpicture\n\t\t\tSET Name = {$Name},\n\t\t\tType = {$Type},\n\t\t\tCarId = {$CarId},\n BlobId = {$BlobId}\n\t\t\tWHERE Id = {$Id}"; if (!mysql_query($sql, $this->connectie)) { die('Error: ' . mysql_error()); } }
public function updateCarMovie($carMovie) { $Id = $carMovie->getId(); $Url = toNull(escape($carMovie->getUrl()), true); $Text = toNull(escape($carMovie->getText()), true); $TypeId = toNull($carMovie->getTypeId(), false); $CarId = toNull($carMovie->getCarId(), false); $sql = "UPDATE carmovie\n\t\t\tSET Url = {$Url},\n\t\t\tText = {$Text},\n\t\t\tTypeId = {$TypeId},\n\t\t\tCarId = {$CarId}\n\t\t\tWHERE Id = {$Id}"; if (!mysql_query($sql, $this->connectie)) { die('Error: ' . mysql_error()); } }
public function updateUser($user) { $Id = $user->getId(); $Name = toNull(escape($user->getName()), true); $Account = toNull(escape($user->getAccount()), true); $Password = toNull(escape($user->getPassword()), true); $Role = toNull(escape($user->getRole()), true); $Email = toNull(escape($user->getEmail()), true); $DateAdded = toNull(toYYYYMMDD($user->getDateAdded()), true); $sql = "UPDATE user\n\t\t\tSET Name = {$Name},\n\t\t\tAccount = {$Account},\n\t\t\tPassword = {$Password},\n\t\t\tRole = {$Role},\n\t\t\tEmail = {$Email},\n\t\t\tDateAdded = {$DateAdded}\n\t\t\tWHERE Id = {$Id}"; if (!mysql_query($sql, $this->connectie)) { die('Error: ' . mysql_error()); } }
public function updateSite($site) { $Id = $site->getId(); $Name = toNull(escape($site->getOriginalName()), true); $DefaultCarId = toNull($site->getDefaultCarId(), false); $DefaultCarBrandId = toNull($site->getDefaultCarBrandId(), false); $OnlyIndexPage = toNull($site->getOnlyIndexPage(), false); $ThumbHeight = toNull($site->getThumbHeight(), false); $ThumbWidth = toNull($site->getThumbWidth(), false); $ParentSiteId = toNull($site->getParentSiteId(), false); $PressContactOverwriteId = toNull($site->getPressContactOverwriteId(), false); $sql = "UPDATE site\n\t\t\tSET Name = {$Name},\n\t\t\tDefaultCarId = {$DefaultCarId},\n\t\t\tDefaultCarBrandId = {$DefaultCarBrandId},\n\t\t\tOnlyIndexPage = {$OnlyIndexPage},\n\t\t\tThumbHeight = {$ThumbHeight},\n\t\t\tThumbWidth = {$ThumbWidth},\n ParentSiteId = {$ParentSiteId},\n PressContactOverwriteId = {$PressContactOverwriteId}\n\t\t\tWHERE Id = {$Id}"; if (!mysql_query($sql, $this->connectie)) { die('Error: ' . mysql_error()); } }
function parse_file($file) { /** * Grabing contents from file */ $handle = fopen($file, 'r'); $content = fread($handle, filesize($file)); $content = trim($content); fclose($handle); /** * splitting the string into an array of lines * Removing first line on title from the array */ // $content_lines = explode(PHP_EOL,$content); // array_shift($content_lines); require 'db.connect.php'; $geoLines = []; $line = ''; $i = 0; $j = 0; while ($i < 2) { if ($content[$j] === '1') { $i++; $j++; } else { $j++; } } $j -= 1; while ($i < 745182) { if ($content[$j] === PHP_EOL) { if (!isset($content[$j])) { break; } if ($i % 5000 === 0) { echo $line . PHP_EOL; } $line = str_replace(array('"'), '', $line); $data = explode(',', $line); $queryData = ['locId' => $data[0], 'country' => $data[1], 'region' => $data[2], 'city' => $data[3], 'postalCode' => $data[4], 'latitude' => $data[5], 'longitude' => $data[6], 'dmaCode' => $data[7], 'areaCode' => $data[8]]; if ($queryData['country'] === 'US') { $query = "\n\t\t\t\t\tINSERT INTO `location`\n\t\t\t\t\t(locId,country,region,city,postalCode,latitude,longitude,dmaCode,areaCode)\n\t\t\t\t\tVALUES (:locId,:country,:region,:city,:postalCode,:latitude,:longitude,:dmaCode,:areaCode);\n\t\t\t\t"; try { $stmt = $dbc->prepare($query); $stmt->bindValue(':locId', $queryData['locId'], PDO::PARAM_INT); $stmt->bindValue(':country', $queryData['country'], PDO::PARAM_STR); $stmt->bindValue(':region', $queryData['region'], PDO::PARAM_STR); $stmt->bindValue(':city', $queryData['city'], PDO::PARAM_STR); $stmt->bindValue(':postalCode', $queryData['postalCode'], PDO::PARAM_STR); $stmt->bindValue(':latitude', $queryData['latitude'], PDO::PARAM_INT); $stmt->bindValue(':longitude', $queryData['longitude'], PDO::PARAM_INT); $stmt->bindValue(':dmaCode', toNull($queryData['dmaCode']), PDO::PARAM_INT); $stmt->bindValue(':areaCode', toNull($queryData['areaCode']), PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { $errors[] = $line; } } // print_r($queryData); $line = ''; $i++; } else { $line .= $content[$j]; } $j++; } // locId int(10) unsigned NOT NULL, // country char(2) NOT NULL, // region char(2) NOT NULL, // city varchar(50), // postalCode char(5) NOT NULL, // latitude float, // longitude float, // dmaCode integer, // areaCode integer, /** * Explode the lines of content into an tempary info array. * * Use the temaray info array to create an associatave array and push onto parks */ // $parks_array = []; // foreach($content_lines as $line) { // $info_array = explode('","',$line); // $parks_array [] = [ // 'name' => substr($info_array[0],1), // 'location' => $info_array[2], // 'date_established' => date("Y-m-d",strtotime($info_array[3])), // 'area' => $info_array[4], // 'description' => substr($info_array[6],0,-1) // ]; // } return $errors; }
$file = new SplFileObject("GeoLiteCity-Location.csv"); while (!$file->eof()) { $line = $file->fgets(); if ($i % 5000 === 0) { echo $line . PHP_EOL; } $i++; $line = str_replace(array('"'), '', $line); $data = explode(',', $line); $queryData = ['locId' => $data[0], 'country' => $data[1], 'region' => $data[2], 'city' => $data[3], 'postalCode' => $data[4], 'latitude' => $data[5], 'longitude' => $data[6], 'dmaCode' => $data[7], 'areaCode' => $data[8]]; if ($queryData['country'] === 'US') { $query = "\n\t\t\tINSERT INTO `location`\n\t\t\t(locId,country,region,city,postalCode,latitude,longitude,dmaCode,areaCode)\n\t\t\tVALUES (:locId,:country,:region,:city,:postalCode,:latitude,:longitude,:dmaCode,:areaCode);\n\t\t"; try { require 'db.connect.php'; $stmt = $dbc->prepare($query); $stmt->bindValue(':locId', $queryData['locId'], PDO::PARAM_INT); $stmt->bindValue(':country', $queryData['country'], PDO::PARAM_STR); $stmt->bindValue(':region', $queryData['region'], PDO::PARAM_STR); $stmt->bindValue(':city', $queryData['city'], PDO::PARAM_STR); $stmt->bindValue(':postalCode', $queryData['postalCode'], PDO::PARAM_STR); $stmt->bindValue(':latitude', $queryData['latitude'], PDO::PARAM_INT); $stmt->bindValue(':longitude', $queryData['longitude'], PDO::PARAM_INT); $stmt->bindValue(':dmaCode', toNull($queryData['dmaCode']), PDO::PARAM_INT); $stmt->bindValue(':areaCode', toNull($queryData['areaCode']), PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { $errors[] = $line; } } } print_r($erros);
if ($string === '') { return null; } else { return $string; } } //$geo_array is the indexed accosiatave array // foreach($geo_array as $index => $row) // { $query = "\n\t\tINSERT INTO `location`\n\t\t(locId,country,region,city,postalCode,latitude,longitude,dmaCode,areaCode)\n\t\tVALUES (:locId,:country,:region,:city,:postalCode,:latitude,:longitude,:dmaCode,:areaCode);\n\t"; $stmt = $dbc->prepare($query); $stmt->bindValue(':locId', '8', PDO::PARAM_INT); $stmt->bindValue(':country', 'AG', PDO::PARAM_STR); $stmt->bindValue(':region', '', PDO::PARAM_STR); $stmt->bindValue(':city', '', PDO::PARAM_STR); $stmt->bindValue(':postalCode', '', PDO::PARAM_STR); $stmt->bindValue(':latitude', '7.0500', PDO::PARAM_INT); $stmt->bindValue(':longitude', '-16.80000', PDO::PARAM_INT); $stmt->bindValue(':dmaCode', toNull(''), PDO::PARAM_INT); $stmt->bindValue(':areaCode', toNull(''), PDO::PARAM_INT); $stmt->execute(); // } // locId int(10) unsigned NOT NULL, // country char(2) NOT NULL, // region char(2) NOT NULL, // city varchar(50), // postalCode char(5) NOT NULL, // latitude float, // longitude float, // dmaCode integer, // areaCode integer,