SlideShare a Scribd company logo
-Overview-
Data Transaction Management
(DTM)
Mr Hery
Dedicated to:
HIT Development Team
http://heryit.esy.es/hitworkstation
Hery Intelligent Technology® JM0670283-X
+60 17-768 1939 / +60 19-709 4691
What is DTM?
• A knowledge to manage data transaction between devices or
platform
• Understanding needs & purposes of data transaction
• Fulfilling safeness & effectiveness of data transaction
What is Data Transaction
• Transfer and receive data between devices or platform
• Commonly used transaction between Database Server and Client
Application (mobile app, desktop app, website)
MySQL
Database
Desktop
App
Mobile
App
Internet
Data Transaction Techniques
• Direct Port Connection Device-to-Device (D2D)
• Webservice (REST API– JSON Data)
Direct Port Connection Technique
• Connection between devices or platform direct to Database Server
• Commonly used in Web Application
• Example;
• Connection between PHP and MySQL Database.
• Client Application need a package installation of Database driver
• Example;
• Android (ART), Xamarin, Classic Windows etc.
• Example;
• Bluetooth, LAN Connection, InfraRed
How Direct Port Connection works?
• Example in PHP with MySQL Database (mysqli method)
Connect PHP to MySQL Database:
$conn = mysqli_connect(“database.host”, “db_username”, “db_password”, “db_name”);
//this method declared that $conn is a MySQL Connection
Querying SQL
$query = mysqli_query($conn, “SELECT * FROM users”);
//this method declared $query as an execution of a SQL Statement
//mysqli_query method require a MySQL Connection - $conn
Fetching Data (print out data) from SQL Query as an Array
$fetch = mysqli_fetch_array($query);
//mysqli_fetch method require a MySQL Query - $query
MySQL
Database
Apache PHP
Server
How Direct Port Connection works?
• Example in PHP with MySQL Database (mysqli method)
Fetching Data (print out data) from SQL Query as an Object
$fetch = mysqli_fetch_object($query);
//mysqli_fetch method require a MySQL Query - $query
Echo / Print out fetched data Array
echo $fetch[“column_name”];
//print single raw data
echo var_dump($fetch);
Echo / print out fetched data Object
echo $fetch->column_name;
//print single raw data
How Direct Port Connection works?
• Example in PHP with MySQL Database (mysqli method)
Generating JSON Data from fetched data Object (single data)
json_encode($fetch);
//Encoding fetch data object to JSON Data
//”echo json_encode()” can be use to print out fetched JSON Data
Generating JSON Data from fetched data Object (multiple data)
while($fetch = mysqli_fetch_object($query)){
$jsonArray[] = $fetch;
//create an Array of multiple Objects
}
json_encode($jsonArray);
//”echo json_encode($jsonArray)” can be use to print out fetched JSON Data
Webservice Technique
• Data Transaction between devices or platform via Webservice
• Transferring text-based data (such as JSON, XML, etc.)
• This technique does not require any installation on Client Application.
• Require HTTP Request method only.
Understanding Webservice
• Client Application send data (called parameter) called Request
• Client Application receive data (JSON Data) called Response
MySQL
Database
Desktop
App
Mobile
App
Internet
(Webservice)
Request
Response
Understanding Webservice
• Request (Header) Type
• GET
• Request GET parameter send via URL
• http://localhost.domain/index.php?user=aiman
• GET parameter is “user” and the value is “aiman”
• Multiple parameter send separate by “&” sign
(?user=aiman&age=18&address=Kluang..)
• POST
• Request POST parameter send via form-data
• This POST Request made secretly by the codes behind the web
Understanding Webservice
• PHP Handling GET Request
Read GET request parameter
$user = $_GET[“user”];
echo $user;
//data printed will be “aiman”
Read POST request parameter
$user = $_POST[“user”];
echo $user;
//data printed will be “aiman”
Understanding Webservice
• Generate JSON Data Response from Request Parameter with MySQL
Request : GET ?content=list&type=user
$type = $_GET[“type”];
$content = $_GET[“list”];
switch($content){
case “list”:
$sql = “SELECT * FROM $type”; //create SQL Statement
break;
}
$query = mysqli_query($conn, $sql); //create executed Query
while($fetch = mysqli_fetch_object($query)){ //fetching Data
$jsonArray[] = $fetch; //create Array of Objects
}
echo json_encode($jsonArray); //generate JSON Object from fetched Data
Thank You
Continue in the Next Chapter Data Transaction Security

More Related Content

What's hot

MongoDb and NoSQL
MongoDb and NoSQLMongoDb and NoSQL
MongoDb and NoSQL
TO THE NEW | Technology
 
Mongo db – document oriented database
Mongo db – document oriented databaseMongo db – document oriented database
Mongo db – document oriented database
Wojciech Sznapka
 
Semantic Technology In Oracle Database 12c
Semantic Technology In Oracle Database 12cSemantic Technology In Oracle Database 12c
Semantic Technology In Oracle Database 12c
Martin Toshev
 

What's hot (20)

MongoDB .local Chicago 2019: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local Chicago 2019: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local Chicago 2019: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local Chicago 2019: MongoDB Atlas Data Lake Technical Deep Dive
 
Building a Directed Graph with MongoDB
Building a Directed Graph with MongoDBBuilding a Directed Graph with MongoDB
Building a Directed Graph with MongoDB
 
Domain-Driven Data at the O'Reilly Software Architecture Conference
Domain-Driven Data at the O'Reilly Software Architecture ConferenceDomain-Driven Data at the O'Reilly Software Architecture Conference
Domain-Driven Data at the O'Reilly Software Architecture Conference
 
Schema Design Best Practices with Buzz Moschetti
Schema Design Best Practices with Buzz MoschettiSchema Design Best Practices with Buzz Moschetti
Schema Design Best Practices with Buzz Moschetti
 
Into to Node.js: Building Fast, Scaleable Network Applications
Into to Node.js: Building Fast, Scaleable Network ApplicationsInto to Node.js: Building Fast, Scaleable Network Applications
Into to Node.js: Building Fast, Scaleable Network Applications
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
MongoDb and NoSQL
MongoDb and NoSQLMongoDb and NoSQL
MongoDb and NoSQL
 
MongoDB
MongoDBMongoDB
MongoDB
 
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorialsMongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
 
Mongo db – document oriented database
Mongo db – document oriented databaseMongo db – document oriented database
Mongo db – document oriented database
 
Semantic Technology In Oracle Database 12c
Semantic Technology In Oracle Database 12cSemantic Technology In Oracle Database 12c
Semantic Technology In Oracle Database 12c
 
FIWARE Wednesday Webinars - Introduction to NGSI-LD
FIWARE Wednesday Webinars - Introduction to NGSI-LDFIWARE Wednesday Webinars - Introduction to NGSI-LD
FIWARE Wednesday Webinars - Introduction to NGSI-LD
 
Java 9 Security Enhancements in Practice
Java 9 Security Enhancements in PracticeJava 9 Security Enhancements in Practice
Java 9 Security Enhancements in Practice
 
Jdk 10 sneak peek
Jdk 10 sneak peekJdk 10 sneak peek
Jdk 10 sneak peek
 
MongoDB .local Houston 2019: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local Houston 2019: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local Houston 2019: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local Houston 2019: MongoDB Atlas Data Lake Technical Deep Dive
 
Data Binding in Silverlight
Data Binding in SilverlightData Binding in Silverlight
Data Binding in Silverlight
 
MongoDB Schema Design by Examples
MongoDB Schema Design by ExamplesMongoDB Schema Design by Examples
MongoDB Schema Design by Examples
 
Mongodb basics and architecture
Mongodb basics and architectureMongodb basics and architecture
Mongodb basics and architecture
 
MongoDB
MongoDBMongoDB
MongoDB
 
Mongo DB Presentation
Mongo DB PresentationMongo DB Presentation
Mongo DB Presentation
 

Similar to Overview to Data Transaction Management

Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
Zoran Jeremic
 
Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)
Igor Moochnick
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 
Evolving your Data Access with MongoDB Stitch
Evolving your Data Access with MongoDB StitchEvolving your Data Access with MongoDB Stitch
Evolving your Data Access with MongoDB Stitch
MongoDB
 

Similar to Overview to Data Transaction Management (20)

Consuming RESTful Web services in PHP
Consuming RESTful Web services in PHPConsuming RESTful Web services in PHP
Consuming RESTful Web services in PHP
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
 
Dojo - from web page to web apps
Dojo - from web page to web appsDojo - from web page to web apps
Dojo - from web page to web apps
 
Implementing and Visualizing Clickstream data with MongoDB
Implementing and Visualizing Clickstream data with MongoDBImplementing and Visualizing Clickstream data with MongoDB
Implementing and Visualizing Clickstream data with MongoDB
 
Data science for infrastructure dev week 2022
Data science for infrastructure   dev week 2022Data science for infrastructure   dev week 2022
Data science for infrastructure dev week 2022
 
Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)
 
Create The Internet of Your Things example of a real system - Laurent Ellerbach
Create The Internet of Your Things example of a real system - Laurent EllerbachCreate The Internet of Your Things example of a real system - Laurent Ellerbach
Create The Internet of Your Things example of a real system - Laurent Ellerbach
 
Rest - Representational State Transfer (EMC BRDC Internal Tech talk)
Rest - Representational State Transfer (EMC BRDC Internal Tech talk)Rest - Representational State Transfer (EMC BRDC Internal Tech talk)
Rest - Representational State Transfer (EMC BRDC Internal Tech talk)
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
Ajax for dummies, and not only.
Ajax for dummies, and not only.Ajax for dummies, and not only.
Ajax for dummies, and not only.
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Introduction to Azure DocumentDB
Introduction to Azure DocumentDBIntroduction to Azure DocumentDB
Introduction to Azure DocumentDB
 
Eagle from eBay at China Hadoop Summit 2015
Eagle from eBay at China Hadoop Summit 2015Eagle from eBay at China Hadoop Summit 2015
Eagle from eBay at China Hadoop Summit 2015
 
Evolving your Data Access with MongoDB Stitch
Evolving your Data Access with MongoDB StitchEvolving your Data Access with MongoDB Stitch
Evolving your Data Access with MongoDB Stitch
 
DevSum'15 : Microsoft Azure and Things
DevSum'15 : Microsoft Azure and ThingsDevSum'15 : Microsoft Azure and Things
DevSum'15 : Microsoft Azure and Things
 
Document Databases & RavenDB
Document Databases & RavenDBDocument Databases & RavenDB
Document Databases & RavenDB
 
Minor Project Progress Presentation
Minor Project Progress PresentationMinor Project Progress Presentation
Minor Project Progress Presentation
 
WPS Application Patterns
WPS Application PatternsWPS Application Patterns
WPS Application Patterns
 
10 Big Data Technologies you Didn't Know About
10 Big Data Technologies you Didn't Know About 10 Big Data Technologies you Didn't Know About
10 Big Data Technologies you Didn't Know About
 
Building Social Enterprise with Ruby and Salesforce
Building Social Enterprise with Ruby and SalesforceBuilding Social Enterprise with Ruby and Salesforce
Building Social Enterprise with Ruby and Salesforce
 

More from Khairi Aiman

More from Khairi Aiman (20)

Sistem HITeCOB - Suruhanjaya Bangunan COB
Sistem HITeCOB - Suruhanjaya Bangunan COBSistem HITeCOB - Suruhanjaya Bangunan COB
Sistem HITeCOB - Suruhanjaya Bangunan COB
 
Xamarin.Form : Basic to Mobile Development
Xamarin.Form : Basic to Mobile DevelopmentXamarin.Form : Basic to Mobile Development
Xamarin.Form : Basic to Mobile Development
 
Overview to Xamarin : Understanding Xamarin Architecture
Overview to Xamarin : Understanding Xamarin ArchitectureOverview to Xamarin : Understanding Xamarin Architecture
Overview to Xamarin : Understanding Xamarin Architecture
 
Xamarin.Forms Application UI XAML Definition
Xamarin.Forms Application UI XAML DefinitionXamarin.Forms Application UI XAML Definition
Xamarin.Forms Application UI XAML Definition
 
C# programming : Chapter One
C# programming : Chapter OneC# programming : Chapter One
C# programming : Chapter One
 
Catalouge 2016 Hery Intelligent Technology
Catalouge 2016 Hery Intelligent TechnologyCatalouge 2016 Hery Intelligent Technology
Catalouge 2016 Hery Intelligent Technology
 
HIT Catalogue 2016
HIT Catalogue 2016HIT Catalogue 2016
HIT Catalogue 2016
 
Prinsip perakaunan tinkatan 4 bab 7 Part 1 - Pelarasan & Mukadimah
Prinsip perakaunan tinkatan 4 bab 7 Part 1 - Pelarasan & MukadimahPrinsip perakaunan tinkatan 4 bab 7 Part 1 - Pelarasan & Mukadimah
Prinsip perakaunan tinkatan 4 bab 7 Part 1 - Pelarasan & Mukadimah
 
Meterpreter in Metasploit User Guide
Meterpreter in Metasploit User GuideMeterpreter in Metasploit User Guide
Meterpreter in Metasploit User Guide
 
Hacking SSL When Using RC4
Hacking SSL When Using RC4Hacking SSL When Using RC4
Hacking SSL When Using RC4
 
Hery Intelligent Technology - Corporate Profile 2015
Hery Intelligent Technology - Corporate Profile 2015Hery Intelligent Technology - Corporate Profile 2015
Hery Intelligent Technology - Corporate Profile 2015
 
CIA Stratergic Communication - September 2004
CIA Stratergic Communication - September 2004CIA Stratergic Communication - September 2004
CIA Stratergic Communication - September 2004
 
Pengaturcaraan C++ - Permarkahan (C++ Programming - Scores)
Pengaturcaraan C++ - Permarkahan (C++ Programming - Scores)Pengaturcaraan C++ - Permarkahan (C++ Programming - Scores)
Pengaturcaraan C++ - Permarkahan (C++ Programming - Scores)
 
Pengaturcaraan C++ - Kalukulator Bulatan (C++ Programming - Circle Calculator)
Pengaturcaraan C++ - Kalukulator Bulatan (C++ Programming - Circle Calculator)Pengaturcaraan C++ - Kalukulator Bulatan (C++ Programming - Circle Calculator)
Pengaturcaraan C++ - Kalukulator Bulatan (C++ Programming - Circle Calculator)
 
13 May 1969
13 May 196913 May 1969
13 May 1969
 
Bahasa kebangsaan
Bahasa kebangsaanBahasa kebangsaan
Bahasa kebangsaan
 
(SOCIAL ENGINEERING - MY) - Psiko rakan kerja
(SOCIAL ENGINEERING - MY) - Psiko rakan kerja(SOCIAL ENGINEERING - MY) - Psiko rakan kerja
(SOCIAL ENGINEERING - MY) - Psiko rakan kerja
 
Burger doll order form
Burger doll order formBurger doll order form
Burger doll order form
 
Kiosk teknologi masa kini - Kajian Soalan
Kiosk teknologi masa kini - Kajian SoalanKiosk teknologi masa kini - Kajian Soalan
Kiosk teknologi masa kini - Kajian Soalan
 
Hack the book Mini
Hack the book MiniHack the book Mini
Hack the book Mini
 

Recently uploaded

Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
YibeltalNibretu
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 

Recently uploaded (20)

Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 

Overview to Data Transaction Management

  • 1. -Overview- Data Transaction Management (DTM) Mr Hery Dedicated to: HIT Development Team http://heryit.esy.es/hitworkstation Hery Intelligent Technology® JM0670283-X +60 17-768 1939 / +60 19-709 4691
  • 2. What is DTM? • A knowledge to manage data transaction between devices or platform • Understanding needs & purposes of data transaction • Fulfilling safeness & effectiveness of data transaction
  • 3. What is Data Transaction • Transfer and receive data between devices or platform • Commonly used transaction between Database Server and Client Application (mobile app, desktop app, website) MySQL Database Desktop App Mobile App Internet
  • 4. Data Transaction Techniques • Direct Port Connection Device-to-Device (D2D) • Webservice (REST API– JSON Data)
  • 5. Direct Port Connection Technique • Connection between devices or platform direct to Database Server • Commonly used in Web Application • Example; • Connection between PHP and MySQL Database. • Client Application need a package installation of Database driver • Example; • Android (ART), Xamarin, Classic Windows etc. • Example; • Bluetooth, LAN Connection, InfraRed
  • 6. How Direct Port Connection works? • Example in PHP with MySQL Database (mysqli method) Connect PHP to MySQL Database: $conn = mysqli_connect(“database.host”, “db_username”, “db_password”, “db_name”); //this method declared that $conn is a MySQL Connection Querying SQL $query = mysqli_query($conn, “SELECT * FROM users”); //this method declared $query as an execution of a SQL Statement //mysqli_query method require a MySQL Connection - $conn Fetching Data (print out data) from SQL Query as an Array $fetch = mysqli_fetch_array($query); //mysqli_fetch method require a MySQL Query - $query MySQL Database Apache PHP Server
  • 7. How Direct Port Connection works? • Example in PHP with MySQL Database (mysqli method) Fetching Data (print out data) from SQL Query as an Object $fetch = mysqli_fetch_object($query); //mysqli_fetch method require a MySQL Query - $query Echo / Print out fetched data Array echo $fetch[“column_name”]; //print single raw data echo var_dump($fetch); Echo / print out fetched data Object echo $fetch->column_name; //print single raw data
  • 8. How Direct Port Connection works? • Example in PHP with MySQL Database (mysqli method) Generating JSON Data from fetched data Object (single data) json_encode($fetch); //Encoding fetch data object to JSON Data //”echo json_encode()” can be use to print out fetched JSON Data Generating JSON Data from fetched data Object (multiple data) while($fetch = mysqli_fetch_object($query)){ $jsonArray[] = $fetch; //create an Array of multiple Objects } json_encode($jsonArray); //”echo json_encode($jsonArray)” can be use to print out fetched JSON Data
  • 9. Webservice Technique • Data Transaction between devices or platform via Webservice • Transferring text-based data (such as JSON, XML, etc.) • This technique does not require any installation on Client Application. • Require HTTP Request method only.
  • 10. Understanding Webservice • Client Application send data (called parameter) called Request • Client Application receive data (JSON Data) called Response MySQL Database Desktop App Mobile App Internet (Webservice) Request Response
  • 11. Understanding Webservice • Request (Header) Type • GET • Request GET parameter send via URL • http://localhost.domain/index.php?user=aiman • GET parameter is “user” and the value is “aiman” • Multiple parameter send separate by “&” sign (?user=aiman&age=18&address=Kluang..) • POST • Request POST parameter send via form-data • This POST Request made secretly by the codes behind the web
  • 12. Understanding Webservice • PHP Handling GET Request Read GET request parameter $user = $_GET[“user”]; echo $user; //data printed will be “aiman” Read POST request parameter $user = $_POST[“user”]; echo $user; //data printed will be “aiman”
  • 13. Understanding Webservice • Generate JSON Data Response from Request Parameter with MySQL Request : GET ?content=list&type=user $type = $_GET[“type”]; $content = $_GET[“list”]; switch($content){ case “list”: $sql = “SELECT * FROM $type”; //create SQL Statement break; } $query = mysqli_query($conn, $sql); //create executed Query while($fetch = mysqli_fetch_object($query)){ //fetching Data $jsonArray[] = $fetch; //create Array of Objects } echo json_encode($jsonArray); //generate JSON Object from fetched Data
  • 14. Thank You Continue in the Next Chapter Data Transaction Security