Database Connection With Mysql

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Database Connection With Mysql - Presentation 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
      • 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
    8. 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
    9. 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
      • 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
    10. Play with PHP
      • Connect to database : mysql_connect("host_name", "db_username", "db_password");
      • Select Database : mysql_select_db("db_name");
    11. 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
    12. 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
    13. Summary
    14. Whats next?

    + Harit KothariHarit Kothari, 2 years ago

    custom

    1313 views, 1 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1313
      • 1313 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 0
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories