Your SlideShare is downloading. ×
Database Connection With Mysql
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Database Connection With Mysql

2,966
views

Published on

Published in: Technology

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,966
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. PHP – Database connection with mysql Harit Kothari [email_address]
  • 2. Agenda
    • Installation
    • service, port, Running through WAMP
    • Database creation
    • Table creation
    • mysqldump and mysqlimport utility
    • phpmyadmin utility
  • 3. Installation
    • Download mysql database installation pack
    • Install it by following manual steps
    • Start mysql service by using appropriate menu
  • 4. service, port, Running through WAMP
    • mysql runs as a OS service
    • This service provides access to database
    • To access, we require 2 parameters:
      • Service host name
      • Port
    • PHP supports many RDBMS
    • mysql is most suitable and famous with PHP
  • 5. Database & Table creation
    • Either use phpmyadmin to create / alter OR
    • Go to mysql prompt and execute as under:
      • shell>create database db_name
      • shell>create table table_name (colname datatype [size] [, ....] constraints...)
  • 6. Data source names / DSN
    • Syntax: dbsyntax://username:password@protocol+hostspec/database
    • Where:
      • dbsyntax represents RDBMS name
      • Username & password of database user for authentication
      • Protocol is optional – e.g. TCP
      • Hostspec is hostname on which datbase service is running
      • Database is actual database name under dbsyntax
  • 7. DSN Examples
    • mysql:///webdb
    • mysql://localhost/webdb
    • mysql://bondview@localhost/webdb
    • mysql://bondview@tcp+localhost/webdb
    • mysql://bondview:007@localhost/webdb
  • 8.
    • Syntax DataBase
    • Mysql MySQL
    • Pgsql PostgreSQL
    • Ibase InterBase
    • Msql Mini SQL
    • Mssql Microsoft SQL Server
    • oci8 Oracle 7/8/8i
    • Odbc ODBC
    • Sybase SyBase
    • Ifx Informix
    • Fbsql FrontBase
  • 9. Database connection
    • $db = DB::connect(DSN [, options ]);
    • DB::isError($db) This will return if any error occurred while connecting to DataBase with DSN
    • Options are:
      • persistent - Connection persists between accesses
      • optimize - What to optimize for
      • debug - Display debugging information
  • 10. Mysqldump – Dumping DataBase
    • A utility to dump database for backup or offline modification
    • A CLI utility that can be executed from SQL prompt to take regular backup of database / table as per requirements
  • 11.
    • Ways to dump sql DB
      • shell> mysqldump [options] db_name [tables]
      • shell> mysqldump [options] --databases db_name1 [db_name2 db_name3...]
      • shell> mysqldump [options] --all-databases
  • 12. Play with PHP
    • Connect to database : mysql_connect("host_name", "db_username", "db_password");
    • Select Database : mysql_select_db("db_name");
  • 13. Mysqlimport – Import data
    • Import database, by importing one oe more text files
    • Syntax: shell> mysqlimport options db_name input_file
    • Useful especially while importing data from CSV files that contains data
  • 14. phpmyadmin
    • Manage mysql database – an administration tool
    • Tool itself written in PHP to manage DataBase effectively and easily
    • Supports operations like create, modify, dump and delete database, table, views etc
    • Very easy to use, GUI
  • 15. Summary
  • 16. Whats next?