Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("db.php");
- include("db_prod.php");
- error_reporting(0);
- // Fill in all the info we need to connect to the database.
- // This is the same info you need even if you're using the old mysql_ library.
- $host = 'localhost';
- $port = 3306; // This is the default port for MySQL
- $database = 'mdataa5_mguides_stage';
- $username = 'mdataa5_mguides';
- $password = '+64^_hO@P3$H';
- // Construct the DSN, or "Data Source Name". Really, it's just a fancy name
- // for a string that says what type of server we're connecting to, and how
- // to connect to it. As long as the above is filled out, this line is all
- // you need :)
- $dsn = "mysql:host=$host;port=$port;dbname=$database";
- // Connect!
- try {
- $db_stage = new PDO("mysql:host=$host;dbname=$database", $username, $password);
- $db_stage->exec("SET time_zone='Europe/Athens';");
- $db_stage->exec("SET NAMES utf8;");
- $db_stage->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
- $db_stage->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $db_stage->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- date_default_timezone_set('Europe/Athens');
- $cur_date = date("Y-m-d H:i");
- // Get all the events checked by the user
- $sel_events = $_POST['migrate'];
- // File update with the migrate log
- $my_file = 'log_'.$cur_date.'.txt';
- $handle = fopen('../../log_files/'.$my_file, 'w') or die('Cannot open file: '.$my_file); //implicitly creates file
- $data = 'Log Date: '.$cur_date."\n";
- echo $data."<br/>";
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $data);
- fclose($handle);
- $venue_ids = array();
- $organizer_ids = array();
- if(empty($sel_events)) {
- echo("You didn't select any events.");
- }
- else {
- events_to_prod(getLastUpdated('events'),$sel_events,$my_file);
- event_kind_to_prod(getLastUpdated('event_kind'),$sel_events,$my_file);
- event_type_to_prod(getLastUpdated('event_type'),$sel_events,$my_file);
- organizers_to_prod(getLastUpdated('organizers'),$organizer_ids,$my_file);
- venues_to_prod(getLastUpdated('venues'),$venue_ids,$my_file);
- cities_to_prod(getLastUpdated('cities'),$my_file);
- // regions_to_prod(getLastUpdated('regions'),$my_file);
- // countries_to_prod(getLastUpdated('countries'),$my_file);
- // continents_to_prod(getLastUpdated('continents'),$my_file);
- files_to_prod(getLastUploaded('venue_uploads'),$my_file);
- }
- function getLastUpdated($table) {
- include("db_prod.php");
- $query='SELECT Datetime_updated FROM '.$table.' ORDER BY Datetime_updated DESC limit 0,1';
- $statement = $db_prod->prepare($query);
- $statement->execute();
- while ($result = $statement->fetchObject()) {
- $venue_last_updated= $result->Datetime_updated;
- }
- $venue_last_updated = date('Y-m-d H:i:s', strtotime($venue_last_updated) - 14400); // $today is today date
- return $venue_last_updated;
- }
- function getLastUploaded($table) {
- include("db_prod.php");
- $query='SELECT date_uploaded FROM '.$table.' ORDER BY date_uploaded DESC limit 0,1';
- $statement = $db_prod->prepare($query);
- $statement->execute();
- while ($result = $statement->fetchObject()) {
- $pdf_last_updated= $result->date_uploaded;
- }
- // $pdf_last_updated = date('Y-m-d H:i:s', strtotime($pdf_last_updated) - 14400); // $today is today date
- return $pdf_last_updated;
- }
- function events_to_prod($since_date, $sel_events, $my_file) {
- include("db.php");
- include("db_mguides_stage.php");
- $place_holders = implode(',', array_fill(0, count($sel_events), '?'));
- $statement = $db->prepare("select * from events where id in ($place_holders)");
- $statement->execute($sel_events);
- $count = $statement->rowCount();
- if($count < 1) {
- $msg = "Events table is already updated!"."\n";
- }
- else {
- $msg = "<b>Events table is being updated....</b>"."\n";
- }
- echo $msg."<br/>";
- $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $msg);
- $since_date = date('Y-m-d H:i:s', strtotime($since_date) + 14400);
- // $since_date = date('Y-m-d H:i:s');
- $todays_date = date('Y-m-d H:i:s');
- // $statement2 = $db->prepare("UPDATE events SET Datetime_updated='$since_date' WHERE id IN ($place_holders)");
- // $statement2->execute($sel_events);
- include("db_prod.php");
- while ($result = $statement->fetchObject()) {
- $id=$result->id;
- $title_en=$result->title_en;
- $title_gr=$result->title_gr;
- $starting_datetime=$result->starting_datetime;
- $starting_datetime = DateTime::createFromFormat('d/m/Y H:i', $starting_datetime)->format('Y/m/d H:i:s');
- $ending_datetime=$result->ending_datetime;
- $ending_datetime = DateTime::createFromFormat('d/m/Y H:i', $ending_datetime)->format('Y/m/d H:i:s');
- $language='BOTH';
- $description_en=$result->description_en;
- $description_gr=$result->description_gr;
- $schedule=$result->schedule;
- $website=$result->website;
- $eof_category=$result->eof_category;
- $specialties_id=$result->specialties_id;
- $organizer_id=$result->organizer_id;
- $organizer_person_id=$result->organizer_person_id;
- $PCO_id=$result->PCO_id;
- $pco_person_id=$result->pco_person_id;
- $venue_id=$result->venue_id;
- $informationsource=$result->informationsource;
- $event_kind_id=$result->event_kind_id;
- $event_type_id=$result->event_type_id;
- $master_conference_id=$result->master_conference_id;
- $keywords=$result->keywords;
- $apple_store=$result->apple_store;
- $play_store=$result->play_store;
- $windows_store=$result->windows_store;
- $Date_created=$result->Date_created;
- $Last_updated_by=$result->Last_updated_by;
- $hide=$result->hide;
- $deleted_by=$result->deleted_by;
- array_push($GLOBALS['venue_ids'], $venue_id);
- array_push($GLOBALS['organizer_ids'], $organizer_id);
- array_push($GLOBALS['organizer_ids'], $PCO_id);
- if(ltrim($result->title_gr)!='' && ltrim($result->title_en)!='') {$title=$result->title_gr.' ('.$result->title_en.')'; }
- else if(ltrim($result->title_gr)=='') {$title= $result->title_en; }
- else {$title= $result->title_gr; }
- $smt = $db_stage->prepare("REPLACE INTO events (id, title_en, title_gr, starting_datetime, ending_datetime, language, website, organizer_id,organizer_person_id,Date_created, Datetime_updated, hide, event_kind_id, event_type_id,venue_id,keywords,description_en,description_gr) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
- $smt->bindValue(1, $id);
- $smt->bindValue(2, $title_en);
- $smt->bindValue(3, $title_gr);
- $smt->bindValue(4, $starting_datetime);
- $smt->bindValue(5, $ending_datetime);
- $smt->bindValue(6, $language);
- $smt->bindValue(7, $website);
- $smt->bindValue(8, 1);
- $smt->bindValue(9, $organizer_id);
- $smt->bindValue(10, $todays_date);
- $smt->bindValue(11, $todays_date);
- $smt->bindValue(12, $hide);
- $smt->bindValue(13, $event_kind_id);
- $smt->bindValue(14, $event_type_id);
- $smt->bindValue(15, $venue_id);
- $smt->bindValue(16, $keywords);
- $smt->bindValue(17, $description_en);
- $smt->bindValue(18, $description_gr);
- /* $smt->bindValue(7, $description_en);
- $smt->bindValue(8, $description_gr);
- $smt->bindValue(9, $schedule);
- $smt->bindValue(10, $website);
- $smt->bindValue(11, $specialties_id);
- $smt->bindValue(12, $organizer_id);
- $smt->bindValue(13, $organizer_person_id);
- $smt->bindValue(14, $PCO_id);
- $smt->bindValue(15, $pco_person_id);
- $smt->bindValue(16, $venue_id);
- $smt->bindValue(17, $informationsource);
- $smt->bindValue(18, $event_kind_id);
- $smt->bindValue(19, $event_type_id);
- $smt->bindValue(20, $master_conference_id);
- $smt->bindValue(21, $keywords);
- $smt->bindValue(22, $apple_store);
- $smt->bindValue(23, $play_store);
- $smt->bindValue(24, $windows_store);
- $smt->bindValue(25, $Date_created);
- $smt->bindValue(26, $since_date);
- // $smt->bindValue(26, $cur_date);
- $smt->bindValue(27, $Last_updated_by);
- $smt->bindValue(28, $hide);
- $smt->bindValue(29, $deleted_by);
- $smt->bindValue(30, $eof_category);
- */
- $smt->execute();
- $message = "Event with id = ".$id." & name = '".$title."'' was inserted succesfully."."\n";
- echo $message."<br/>";
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $message);
- }
- echo "Events updated:".count($sel_events)."<br/>";
- fclose($handle);
- }
- function organizers_to_prod($since_date,$organizer_ids, $my_file) {
- include("db.php");
- include("db_mguides_stage.php");
- $place_holders = implode(',', array_fill(0, count($organizer_ids), '?'));
- $statement = $db->prepare("select * from organizers where id in ($place_holders)");
- $statement->execute($organizer_ids);
- $count = $statement->rowCount();
- if($count < 1) {
- $msg = "Organizers table is already updated!"."\n";
- }
- else {
- $msg = "<b>Organizers table is being updated....</b>"."\n";
- }
- echo $msg."<br/>";
- $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $msg);
- $since_date = date('Y-m-d H:i:s', strtotime($since_date) + 14400);
- $todays_date = date('Y-m-d H:i:s');
- include("db_prod.php");
- while ($result = $statement->fetchObject()) {
- $id=$result->id;
- $type_id=$result->type_id;
- $name=$result->name;
- $telephone=$result->telephone;
- $email=$result->email;
- $address=$result->address;
- $zip=$result->zip;
- $city_id=$result->city_id;
- $website=$result->website;
- $fax=$result->fax;
- $type=$result->type;
- $hide=$result->hide;
- $Last_updated_by=$result->Last_updated_by;
- $deleted_by=$result->deleted_by;
- $Datetime_updated=$result->Datetime_updated;
- //app_organizer_lang
- $smt = $db_stage->prepare("REPLACE INTO app_organizer_lang (id,organizer_id,locale,title,about,summary,detail_info,address,createdon,updatedon,hide) VALUES (?,?,?,?,?,?,?,?,?,?,?); ");
- $smt->bindValue(1, $id);
- $smt->bindValue(2, $id);
- $smt->bindValue(3, 'en');
- $smt->bindValue(4, $name);
- $smt->bindValue(5, '');
- $smt->bindValue(6, '');
- $smt->bindValue(7, '');
- $smt->bindValue(8, $address);
- $smt->bindValue(9, $todays_date);
- $smt->bindValue(10, $todays_date);
- $smt->bindValue(11, $hide);
- $smt->execute();
- $message = "Organizer with id = ".$id." & name = '".$name."'' was inserted succesfully."."\n";
- echo $message."<br/>";
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $message);
- //app_organizer
- $smt = $db_stage->prepare("REPLACE INTO app_organizer (id,organizer_id,sponser_type_id,image,website,mobile,telephone,email,facebook,youtube,twitter,linkedin,createdon,updatedon,ordering,hide) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?); ");
- $smt->bindValue(1, $id);
- $smt->bindValue(2, $id);
- $smt->bindValue(3, 0);
- $smt->bindValue(4, '');
- $smt->bindValue(5, $website);
- $smt->bindValue(6, '');
- $smt->bindValue(7, $telephone);
- $smt->bindValue(8, $email);
- $smt->bindValue(9, '');
- $smt->bindValue(10, '');
- $smt->bindValue(11, '');
- $smt->bindValue(12, '');
- $smt->bindValue(13, $todays_date);
- $smt->bindValue(14, $todays_date);
- $smt->bindValue(15, '');
- $smt->bindValue(16, $hide);
- $smt->execute();
- $message = "Organizer with id = ".$id." & name = '".$name."'' was inserted succesfully."."\n";
- echo $message."<br/>";
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $message);
- }
- echo "Organizers / PCOs updated:".count(array_unique(array_filter($organizer_ids)))."<br/>";
- fclose($handle);
- }
- function event_kind_to_prod($since_date,$organizer_ids, $my_file) {
- include("db.php");
- include("db_mguides_stage.php");
- $todays_date = date('Y-m-d H:i:s');
- $place_holders = implode(',', array_fill(0, count($organizer_ids), '?'));
- $statement = $db->prepare("select * from event_kind");
- $statement->execute();
- $count = $statement->rowCount();
- if($count < 1) {
- $msg = "Event kind table is already updated!"."\n";
- }
- else {
- $msg = "<b>Event kind table is being updated....</b>"."\n";
- }
- echo $msg."<br/>";
- $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $msg);
- $since_date = date('Y-m-d H:i:s', strtotime($since_date) + 14400);
- $todays_date = date('Y-m-d H:i:s');
- include("db_prod.php");
- while ($result = $statement->fetchObject()) {
- $id=$result->id;
- $name_en=$result->name_en;
- $name_gr=$result->name_gr;
- $Datetime_updated=$result->Datetime_updated;
- $hide=$result->hide;
- //Event kind
- $smt = $db_stage->prepare("REPLACE INTO event_kind (id,name_en,name_gr,Datetime_updated,hide) VALUES (?,?,?,?,?); ");
- $smt->bindValue(1, $id);
- $smt->bindValue(2, $name_en);
- $smt->bindValue(3, $name_gr);
- $smt->bindValue(4, $todays_date);
- $smt->bindValue(5, $hide);
- $smt->execute();
- }
- fclose($handle);
- }
- function event_type_to_prod($since_date,$organizer_ids, $my_file) {
- include("db.php");
- include("db_mguides_stage.php");
- $todays_date = date('Y-m-d H:i:s');
- $place_holders = implode(',', array_fill(0, count($organizer_ids), '?'));
- $statement = $db->prepare("select * from event_type");
- $statement->execute();
- $count = $statement->rowCount();
- if($count < 1) {
- $msg = "Event type table is already updated!"."\n";
- }
- else {
- $msg = "<b>Event type table is being updated....</b>"."\n";
- }
- echo $msg."<br/>";
- $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $msg);
- $since_date = date('Y-m-d H:i:s', strtotime($since_date) + 14400);
- $todays_date = date('Y-m-d H:i:s');
- include("db_prod.php");
- while ($result = $statement->fetchObject()) {
- $id=$result->id;
- $name_en=$result->name_en;
- $name_gr=$result->name_gr;
- $Datetime_updated=$result->Datetime_updated;
- $hide=$result->hide;
- //Event kind
- $smt = $db_stage->prepare("REPLACE INTO event_type (id,name_en,name_gr,Datetime_updated,hide) VALUES (?,?,?,?,?); ");
- $smt->bindValue(1, $id);
- $smt->bindValue(2, $name_en);
- $smt->bindValue(3, $name_gr);
- $smt->bindValue(4, $todays_date);
- $smt->bindValue(5, $hide);
- $smt->execute();
- }
- fclose($handle);
- }
- function venues_to_prod($since_date,$venue_ids,$my_file) {
- include("db.php");
- include("db_mguides_stage.php");
- $todays_date = date('Y-m-d H:i:s');
- $place_holders = implode(',', array_fill(0, count($venue_ids), '?'));
- $statement = $db->prepare("select * from venues where id in ($place_holders)");
- $statement->execute($venue_ids);
- $count = $statement->rowCount();
- if($count < 1) {
- $msg = "Venues table is already updated!"."\n";
- }
- else {
- $msg = "<b>Venues table is being updated....</b>"."\n";
- }
- echo $msg."<br/>";
- $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $msg);
- $since_date = date('Y-m-d H:i:s', strtotime($since_date) + 14400);
- include("db_prod.php");
- while ($result = $statement->fetchObject()) {
- $id=$result->id;
- $name=$result->name;
- $type=$result->type;
- $address=$result->address;
- $zip=$result->zip;
- $longtitude=$result->longtitude;
- $latitude=$result->latitude;
- $city_id=$result->city_id;
- $telephone=$result->telephone;
- $website=$result->website;
- $email=$result->email;
- $fax=$result->fax;
- $supervisor_name=$result->supervisor_name;
- $supervisor_last=$result->supervisor_last;
- $supervisor_phone=$result->supervisor_phone;
- $supervisor_email=$result->supervisor_email;
- $material_url = $result->material_url;
- $venue_pdf=$result->venue_pdf;
- $Datetime_updated=$result->Datetime_updated;
- $hide=$result->hide;
- $Last_updated_by=$result->Last_updated_by;
- $deleted_by=$result->deleted_by;
- $smt = $db_stage->prepare("REPLACE INTO venues (id,name,address,name_en,address_en,longtitude,latitude,city_id,telephone,website,email,Datetime_updated,hide,organizer_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?); ");
- $smt->bindValue(1, $id);
- $smt->bindValue(2, $name);
- $smt->bindValue(3, $address);
- $smt->bindValue(4, $name);
- $smt->bindValue(5, $address);
- $smt->bindValue(6, $longtitude);
- $smt->bindValue(7, $latitude);
- $smt->bindValue(8, $city_id);
- $smt->bindValue(9, $telephone);
- $smt->bindValue(10, $website);
- $smt->bindValue(11, $email);
- $smt->bindValue(12, $todays_date);
- $smt->bindValue(13, $hide);
- $smt->bindValue(14, 1);
- $smt->execute();
- $message = "Venue with id = ".$id." & name ='".$name."'' was inserted succesfully "."\n";
- echo $message."<br/>";
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $message);
- }
- echo "Venues updated:".count(array_unique(array_filter($venue_ids)))."<br/>";
- fclose($handle);
- }
- function cities_to_prod($since_date,$my_file) {
- include("db.php");
- include("db_mguides_stage.php");
- $todays_date = date('Y-m-d H:i:s');
- $query='select * from cities where Datetime_updated > ?';
- $statement = $db->prepare($query);
- $statement->execute(array($since_date));
- //var_dump($result);
- $count = $statement->rowCount();
- if($count < 1) {
- $msg = "Cities table is already updated!"."\n";
- }
- else {
- $msg = "<b>Cities table is being updated....</b>"."\n";
- }
- echo $msg."<br/>";
- $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $msg);
- include("db_prod.php");
- while ($result = $statement->fetchObject()) {
- $id=$result->id;
- $name_gr=$result->name_gr;
- $name_en=$result->name_en;
- $region_id=$result->region_id;
- $latitude=$result->latitude;
- $longitude=$result->longitude;
- $description=$result->description;
- $Last_updated_by=$result->Last_updated_by;
- $hide=$result->hide;
- $deleted_by=$result->deleted_by;
- $smt = $db_stage->prepare("REPLACE INTO cities (id,name_gr,name_en,region_id,latitude,longitude,description,Last_updated_by,hide,deleted_by) VALUES (?,?,?,?,?,?,?,?,?,?); ");
- $smt->bindValue(1, $id);
- $smt->bindValue(2, $name_gr);
- $smt->bindValue(3, $name_en);
- $smt->bindValue(4, $region_id);
- $smt->bindValue(5, $latitude);
- $smt->bindValue(6, $longitude);
- $smt->bindValue(7, $description);
- $smt->bindValue(8, $Last_updated_by);
- $smt->bindValue(9, $hide);
- $smt->bindValue(10, $deleted_by);
- $smt->execute();
- $message = "city with id = ".$id." & name = '".$name_gr."'' was inserted succesfully."."\n";
- echo $message."<br/>";
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $message);
- }
- fclose($handle);
- }
- function continents_to_prod($since_date,$my_file) {
- include("db.php");
- $query='select * from continents where Datetime_updated > ?';
- $statement = $db->prepare($query);
- $statement->execute(array($since_date));
- //var_dump($result);
- $count = $statement->rowCount();
- if($count < 1) {
- $msg = "Continents table is already updated!"."\n";
- }
- else {
- $msg = "<b>Continents table is being updated....</b>"."\n";
- }
- echo $msg."<br/>";
- $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $msg);
- include("db_prod.php");
- while ($result = $statement->fetchObject()) {
- $id=$result->id;
- $name_gr=$result->name_gr;
- $name_en=$result->name_en;
- $hide=$result->Hide;
- $Last_updated_by=$result->Last_updated_by;
- $deleted_by=$result->deleted_by;
- $smt = $db_prod->prepare("REPLACE INTO continents (id,name_gr,name_en,Hide,Last_updated_by,deleted_by) VALUES (?,?,?,?,?,?); ");
- $smt->bindValue(1, $id);
- $smt->bindValue(2, $name_gr);
- $smt->bindValue(3, $name_en);
- $smt->bindValue(4, $hide);
- $smt->bindValue(5, $Last_updated_by);
- $smt->bindValue(6, $deleted_by);
- $smt->execute();
- $message = "Continent with id = ".$id." & name = '".$name_gr."'' was inserted succesfully."."\n";
- echo $message."<br/>";
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $message);
- }
- fclose($handle);
- }
- function countries_to_prod($since_date,$my_file) {
- include("db.php");
- $query='select * from countries where Datetime_updated > ?';
- $statement = $db->prepare($query);
- $statement->execute(array($since_date));
- //var_dump($result);
- $count = $statement->rowCount();
- if($count < 1) {
- $msg = "Countries table is already updated!"."\n";
- }
- else {
- $msg = "<b>Countries table is being updated....</b>"."\n";
- }
- echo $msg."<br/>";
- $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $msg);
- include("db_prod.php");
- while ($result = $statement->fetchObject()) {
- $id=$result->id;
- $name_gr=$result->name_gr;
- $name_en=$result->name_en;
- $continent_id=$result->continent_id;
- $hide=$result->hide;
- $Last_updated_by=$result->Last_updated_by;
- $deleted_by=$result->deleted_by;
- $smt = $db_prod->prepare("REPLACE INTO countries (id,name_gr,name_en,continent_id,hide,Last_updated_by,deleted_by) VALUES (?,?,?,?,?,?,?); ");
- $smt->bindValue(1, $id);
- $smt->bindValue(2, $name_gr);
- $smt->bindValue(3, $name_en);
- $smt->bindValue(4, $continent_id);
- $smt->bindValue(5, $hide);
- $smt->bindValue(6, $Last_updated_by);
- $smt->bindValue(7, $deleted_by);
- $smt->execute();
- $message = "Country with id = ".$id." & name = '".$name_gr."'' was inserted succesfully."."\n";
- echo $message."<br/>";
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $message);
- }
- fclose($handle);
- }
- function regions_to_prod($since_date,$my_file)
- {
- include("db.php");
- $query='select * from regions where Datetime_updated > ?';
- $statement = $db->prepare($query);
- $statement->execute(array($since_date));
- //var_dump($result);
- $count = $statement->rowCount();
- if($count < 1) {
- $msg = "Regions table is already updated!"."\n";
- }
- else {
- $msg = "<b>Regions table is being updated....</b>"."\n";
- }
- echo $msg."<br/>";
- $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $msg);
- include("db_prod.php");
- while ($result = $statement->fetchObject()) {
- $id=$result->id;
- $name_gr=$result->name_gr;
- $name_en=$result->name_en;
- $country_id=$result->country_id;
- $hide=$result->hide;
- $Last_updated_by=$result->Last_updated_by;
- $deleted_by=$result->deleted_by;
- $smt = $db_prod->prepare("REPLACE INTO regions (id,name_gr,name_en,country_id,hide,Last_updated_by,deleted_by) VALUES (?,?,?,?,?,?,?); ");
- $smt->bindValue(1, $id);
- $smt->bindValue(2, $name_gr);
- $smt->bindValue(3, $name_en);
- $smt->bindValue(4, $country_id);
- $smt->bindValue(5, $hide);
- $smt->bindValue(6, $Last_updated_by);
- $smt->bindValue(7, $deleted_by);
- $smt->execute();
- $message = "region with id = ".$id." & name = '".$name_gr."'' was inserted succesfully."."\n";
- echo $message."<br/>";
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $message);
- }
- fclose($handle);
- }
- function files_to_prod($since_date,$my_file) {
- include("db.php");
- include("db_mguides_stage.php");
- $todays_date = date('Y-m-d H:i:s');
- $query='select * from venue_uploads where date_uploaded > ?';
- $statement = $db->prepare($query);
- $statement->execute(array($since_date));
- //var_dump($result);
- $count = $statement->rowCount();
- if($count < 1) {
- $msg = "Files table is already updated!"."\n";
- }
- else {
- $msg = "<b>Files table is being updated....</b>"."\n";
- }
- echo $msg."<br/>";
- $handle = fopen('../../log_files/'.$my_file, 'a') or die('Cannot open file: '.$my_file);
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $msg);
- include("db_prod.php");
- while ($result = $statement->fetchObject()) {
- $id=$result->id;
- $name=$result->name;
- $file_path=$result->file_path;
- $date_uploaded=$result->date_uploaded;
- $smt = $db_prod->prepare("REPLACE INTO event_document (id,name,file_path,date_uploaded) VALUES (?,?,?,?); ");
- $smt->bindValue(1, $id);
- $smt->bindValue(2, $name);
- $smt->bindValue(3, $file_path);
- $smt->bindValue(4, $date_uploaded);
- $smt->execute();
- $message = "File with id = ".$id." & name = '".$name."'' was inserted succesfully."."\n";
- echo $message."<br/>";
- fwrite($handle, pack("CCC",0xef,0xbb,0xbf));
- fwrite($handle, $message);
- }
- fclose($handle);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement