How does NEST read data from NMDB. Connection to database //Get the connection data from an external file $fp = fopen('connection_file', 'r'); if($fp){

Slides:



Advertisements
Similar presentations
Implementing Tableau Server in an Enterprise Environment
Advertisements

Copyright © 2003 Pearson Education, Inc. Slide 6b-1 The Web Wizards Guide to PHP by David Lash.
LIS651 lecture 3 taming PHP Thomas Krichel
PHP II Interacting with Database Data. The whole idea of a database-driven website is to enable the content of the site to reside in a database, and to.
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Course Readings in Learning Management Systems Mike Waugh Louisiana State University Eric Frierson EBSCO Information Services CNI Spring Meeting 2014.
MySQL Access Privilege System
Aqua Data Studio. Find the application We are using Aqua Data Studio v11.
PHP and MySQL Database. Connecting to MySQL Note: you need to make sure that you have MySQL software properly installed on your computer before you attempt.
1 Web Servers / Deployment Alastair Dawes Original by Bhupinder Reehal.
Compe 341 Oracle Installation Procedure. Oracle From Click.
PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.
Encrypted Passwords. your_password + username $u = crypt ( your_password ) PHP insert username + $u SQL MySQL database username | encrypted password username.
FTP File Transfer Protocol. Introduction transfer file to/from remote host client/server model  client: side that initiates transfer (either to/from.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Class 3 MySQL Robert Mudge Reference:
Cookies Set a cookie – setcookie() Extract data from a cookie - $_COOKIE Augment user authentication script with a cookie.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
Eurotrace Hands-On The Eurotrace File System. 2 The Eurotrace file system Under MS ACCESS EUROTRACE generates several different files when you create.
Accessing MySQL with PHP IDIA 618 Fall 2014 Bridget M. Blodgett.
PHP MySQL. SQL: Tables CREATE TABLE tablename { fieldname type(length) extra info,... } Extra info: –NULL (allows nulls in this field) –Not NULL (null.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
ISYS 475 Project: Customizing a Zen Cart E-Commerce Site.
PHP+MySQL Integration. Connecting to databases One of the most common tasks when working with dynamic webpages is connecting to a database which holds.
MySQL Database Connection
Intro to DatabasesClass 4 SQL REVIEW To talk to the database, you have to use SQL SQL is used by many databases, not just MySQL. SQL stands for Structured.
Chapter 8 File-Oriented Input and Output. 8.1 INTRODUCTION a file can also be designed to store data. We can easily update files, A data file as input.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
COOKIES and SESSIONS. COOKIES A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each.
Web Programming Language Week 7 Dr. Ken Cosh PHP and storage.
Storing and Retrieving Data
Outline Overview Opening a file How to create a file ? Closing a File Check End-of-file Reading a File Line by Line Reading a File Character by Character.
PHP 4 Files, Functions. Opening a File The fopen() function is used to open files in PHP. The first parameter of this function contains the name of the.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Files & Directories.
Controlling Web Site Access Using Logins CS 320. Basic Approach HTML form a php page that collects the username and password  Sends them to second PHP.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
MySQL. Is a SQL (Structured Query Language) database server. Can be accessed using PHP with embedded SQL Queries Supports Large DB’s, 60,000 tables with.
Accessing mySQL relational database. MySQL database.  Today, we will attempt and open a connection to the MySQL server.  We need to specify the database.
NMED 3850 A Advanced Online Design January 14, 2010 V. Mahadevan.
Database MySQL Universitas Muhammadiyah Surakarta Yogiek Indra Kurniawan.
>> PHP: MySQL & CRUD. R ecall Database Tables Records is composed of Operations (CRUD) Create Retrieve Update Delete DBMS Access Control MySQL phpMyAdmin.
Class 3Intro to Databases Class 4 Simple Example of a Database We’re going to build a simple example of a database, which will allow us to register users.
GAME203 – C Files stdio.h C standard Input/Output “getchar()”
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
MySQL MySQL and PHP – interacting with a database.
 To start using PHP, you can:  Find a web host with PHP and MySQL support  Install a web server on your own PC, and then install PHP and MySQL.
Display Page (HTML/CSS)
Files A collection of related data treated as a unit. Two types Text
Log into the Simplicity Website User Name: Password: africa55Simplicity
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 3 PHP Advanced.
Chapter 9 Lecture 4. NetWare Novell’s network operating system Biggest competitor – Microsoft Windows.
Slide Set #24: Database security SY306 Web and Databases for Cyber Operations.
DATABASE ACCESS CONTROL IST Question Almost every PHP page needs to interact with database, does that mean sqlUsername and sqlPassword need to be.
H OW TO INSTALL W ORDPRESS MANUALLY Enukesoftware.com.
Advance OOP in PHP.
Installation First Server
File Input/Output.
Bioinformatics Research Group
MySQL tutorial.
My EBSCOhost Tutorial Tutorial support.ebsco.com.
File Transfer Protocol
Web Programming Language
Web Servers / Deployment
Information Architecture in OU Campus
Create New User in Database. First Connect the System.
PHP: Database connection
Database Management Systems
Designing Databases ySQL Happy Meal Example.
Presentation transcript:

How does NEST read data from NMDB

Connection to database //Get the connection data from an external file $fp = fopen('connection_file', 'r'); if($fp){ //username and password should be the first 2 lines of the file $username = rtrim(fgets($fp)); $password = rtrim(fgets($fp)); while(!feof($fp)){ $hosts[] = rtrim(fgets($fp)); } fclose($fp); Connection file is not stored in the same directory as the website: no access to external users if($username && $password && $hosts){ foreach($hosts as $host){ if(!$link){ $link = mysql_connect($host, $username, $password); }//try first db04,then db10, db20 etc… } if(!$link){die("Impossible to connect : ". mysql_error());} } else { print "Connection parameters could not be retrieved "; } mysql_select_db('nmdb', $link) or die('Could not select database.');

SELECT start_date_time, measured_corr_for_efficiency FROM KERG_ori WHERE start_date_time >= ' :00:00' AND start_date_time <= ' :59:00' ORDER BY start_date_time ASC Simple case BUILD THE MYSQL QUERY Here we ask for the original corrected for efficiency data from KERG station between 2 dates: no table join and no average

SELECT o.start_date_time, CASE WHEN r.start_date_time IS NULL THEN o.measured_corr_for_efficiency ELSE r.revised_corr_for_efficiency END AS corr_for_efficiency FROM KERG_ori o LEFT JOIN KERG_rev r ON o.start_date_time = r.start_date_time WHERE o.start_date_time >= ' :00:00' AND o.start_date_time <= ' :59:00' ORDER BY start_date_time ASC Revised original case: table join BUILD THE MYSQL QUERY Here we ask for the revised corrected for efficiency data from KERG station between 2 dates. We need to look in 2 tables, original and revised :41: :42: :43: :44: :45: :46: :47: :44: :47:00 NULL

Average original data over 5 min: simplified version BUILD THE MYSQL QUERY SELECT start_date_time, AVG( measured_corr_for_efficiency ) AS measured_corr_for_efficiency FROM KERG_ori WHERE start_date_time >= ' :00:00' AND start_date_time <= ' :59:00' GROUP BY FLOOR ( UNIX_TIMESTAMP (start_date_time) / 300 ) UNIX_TIMESTAMP: number of seconds since ' :00:00' FLOOR (1.23) = 1 We group the start_date_time with the same « floor » result Ex: s / 300 = will be in the same group as s / 300 = but not BUT unix_timestamp does not work for dates before 1970

SELECT start_date_time, AVG( measured_corr_for_efficiency ) AS measured_corr_for_efficiency FROM KERG_ori WHERE start_date_time >= ' :00:00' AND start_date_time <= ' :59:00' GROUP BY FLOOR( (TIME_TO_SEC( TIME( start_date_time ) ) * TO_DAYS( start_date_time ) ) / ( 300 ) ) Average original data over 5 min: simplified version 2 BUILD THE MYSQL QUERY TIME function extract the hour part of start_date_time, Which is then converted to seconds. TO_DAYS gives the number of days since year 0 and works well for years after This number is converted to seconds and added to the first part. BUT weird behaviour of selected start_date_time OULU start_date_time 1HCOR_E :00:00; :00:00; :00:00; :00:00; :00:00; :00:00; :00:00; :00:00; :00:00; OULU start_date_time 1HCOR_E :00:00; :00:00; :00:00; :00:00; :00:00; :00:00; :00:00; :00:00; :00:00;

SELECT DATE_ADD( ' :00:00', INTERVAL 300 * FLOOR( (TIME_TO_SEC( TIME( start_date_time ) ) * ( TO_DAYS( start_date_time ) -1 ) ) / ( 300 ) ) SECOND ) AS start_date_time, AVG( measured_corr_for_efficiency ) AS measured_corr_for_efficiency FROM KERG_ori WHERE start_date_time >= ' :00:00' AND start_date_time <= ' :59:00' GROUP BY FLOOR( (TIME_TO_SEC( TIME( start_date_time ) ) * TO_DAYS( start_date_time ) ) / ( 300 ) ) Average original data over 5 min: full version BUILD THE MYSQL QUERY DATE_ADD(date,INTERVAL N SECOND) will add N seconds to date (-1 to account for start_date of date_add)

SELECT DATE_ADD( ' :00:00', INTERVAL 300 * FLOOR( (TIME_TO_SEC( TIME( subq.start_date_time ) ) * ( TO_DAYS( subq.start_date_time ) -1 ) ) / ( 300 )) SECOND ) AS start_date_time, AVG( subq.corr_for_efficiency ) AS corr_for_efficiency FROM ( SELECT o.start_date_time, CASE WHEN r.start_date_time IS NULL THEN o.measured_corr_for_efficiency ELSE r.revised_corr_for_efficiency END AS corr_for_efficiency FROM KERG_ori o LEFT JOIN KERG_rev r ON o.start_date_time = r.start_date_time WHERE o.start_date_time >= ' :00:00' AND o.start_date_time <= ' :59:00' ORDER BY start_date_time ASC ) AS subq GROUP BY FLOOR( (TIME_TO_SEC( TIME( subq.start_date_time ) ) * TO_DAYS( subq.start_date_time ) ) / ( 300 ) ) ORDER BY start_date_time ASC Averaged revised data BUILD THE MYSQL QUERY The query for revised data is used a subquery in the average query $rs = mysql_query($query);