0% found this document useful (0 votes)
11 views

Rdms nots bca php

A Relational Database Management System (RDBMS) organizes data into structured tables and is commonly accessed using Structured Query Language (SQL). MySQL, a popular open-source RDBMS, can be connected to PHP through MySQLi and PDO extensions, with options for both object-oriented and procedural programming. The document provides examples of connecting to a MySQL database and creating a new database using PHP code.

Uploaded by

bp110673
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Rdms nots bca php

A Relational Database Management System (RDBMS) organizes data into structured tables and is commonly accessed using Structured Query Language (SQL). MySQL, a popular open-source RDBMS, can be connected to PHP through MySQLi and PDO extensions, with options for both object-oriented and procedural programming. The document provides examples of connecting to a MySQL database and creating a new database using PHP code.

Uploaded by

bp110673
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Introduction To RDMS

A Relational Database Management System (RDBMS) is a server that manages


data for you. The data is structured into tables, where each table has a number
of columns, each of which has a name and a type. Tables are grouped together
into databases, RDBMS usually has its own user system, which controls access
rights for databases PHP communicates with relational databases such as MySQL
and Oracle using the Structured Query Language (SQL). You can use SQL to
create, modify, and query relational databases.

Structured Query Language (SQL). The data in a MySQL database are stored in
tables that consist of columns and rows. MySQL is an open-source relational
database management system (RDBMS). It is the most popular database system
used with PHP.
Structured Query Language (SQL). The data in a MySQL database are stored in
tables that consist of columns and rows.
MySQL is a database system that runs on a server. MySQL is ideal for both small
and large applications. MySQL is a very fast, reliable, and easy-to-use database
system. It uses standard SQL. MySQL compiles on a number of platforms.

PHP MySQL Connect:


Two extensions are used to connect with database in PHP as following:
 MySQLi extension (the "i" stands for improved)
 PDO (PHP Data Objects
MYSQLi extensions further used as two ways:

 MySQLi (object-oriented)
 MySQLi (procedural)

MySQLi (object-oriented):

PHP mysqli() function is used to connect with MySQL database.

Syntax for create connection:

mysqli($servername, $username, $password);

close connection:

close() function is used to disconnect the connection with mysql database.

Syntax for close connection:

Close();
MySQLi (procedural):

PHP mysqli_connect() function is used to connect with MySQL database.

Synatx for create connection:

mysqli_connect($servername, $username, $password);

Close connection:

PHP mysqli_close() function is used to disconnect with MySQL database.


Syntax

mysqli_close($conn);

PHP MySQL Connect Example


Example
1. <?php
2. $servername = 'localhost'; // host name
3. $username = '';
4. $password = '';
5. $conn=mysql(($servername, $username, $password); // connection
mysqli object oriented
$conn = mysqli_connect($servername, $username, $password); //
connection mysqli procedural
6. if(! $conn )
7. {
8. die('Could not connect: ' . mysqli_error());
9. }
10.echo 'Connected successfully';
11.close($conn);// close connection for mysqli object oriented
mysqli_close($conn); // close connection in mysqli procedural
12.?>

PHP MySQL Create Database


o mysqli_query() function is used to create database

PHP MySQLi Create Database Example


Example
1. <?php
2. $host = 'localhost';
3. $user = '';
4. $pass = '';
5. $conn = mysqli_connect($host, $user, $pass);
6. if(! $conn )
7. {
8. die('Could not connect: ' . mysqli_connect_error());
9. }
10.echo 'Connected successfully<br/>';
11.$sql = 'CREATE Database mydb'; // mydb is a database name
12.if(mysqli_query( $conn,$sql))
13.{
14. echo "Database mydb created successfully.";
15.}
16.Else
17.{
18.echo "Sorry, database creation failed ".mysqli_error($conn);
19.}
20.mysqli_close($conn);
21.?>

You might also like