lecture 3 mysql database. php mysql connection mysql is a database system used on the web mysql is a...

9
LECTURE 3 MYSQL Database

Upload: bruno-richardson

Post on 19-Jan-2016

227 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: LECTURE 3 MYSQL Database. PHP MYSQL CONNECTION MySQL is a database system used on the web MySQL is a database system that runs on a server MySQL is ideal

LECTURE 3

MYSQL Database

Page 2: LECTURE 3 MYSQL Database. PHP MYSQL CONNECTION MySQL is a database system used on the web MySQL is a database system that runs on a server MySQL is ideal

PHP MYSQL CONNECTIONMySQL is a database system used on the webMySQL is a database system that runs on a serverMySQL is ideal for both small and large applicationsMySQL is very fast, reliable, and easy to useMySQL uses standard SQLMySQL compiles on a number of platformsMySQL is free to download and useMySQL is developed, distributed, and supported by Oracle CorporationMySQL is named after co-founder Monty Widenius's daughter: My

Page 3: LECTURE 3 MYSQL Database. PHP MYSQL CONNECTION MySQL is a database system used on the web MySQL is a database system that runs on a server MySQL is ideal

PHP + MySQL Database System

• PHP combined with MySQL are cross-platform (you can develop in Windows and serve on a Unix platform)

Page 4: LECTURE 3 MYSQL Database. PHP MYSQL CONNECTION MySQL is a database system used on the web MySQL is a database system that runs on a server MySQL is ideal

Example (MySQLi Object-Oriented)<?php

$connection = new mysqli("localhost","ilyasgalacticos","","facebook");$connected = false;if(!$connection->connect_error){

$connected = true;} if($connected){

$query = $connection->query(“ SELECT * FROM users “);

while($row = $query->fetch_object()){ echo "<h1>".$row->id."</h1>";

echo "<h1>".$row->login."</h1>";echo "<h1>".$row->password."</h1>";

echo "<h1>".$row->age."</h1>"; echo "<h1>".$row->full_name."</h1>";}

}?>

Page 5: LECTURE 3 MYSQL Database. PHP MYSQL CONNECTION MySQL is a database system used on the web MySQL is a database system that runs on a server MySQL is ideal

RESULT:

Page 6: LECTURE 3 MYSQL Database. PHP MYSQL CONNECTION MySQL is a database system used on the web MySQL is a database system that runs on a server MySQL is ideal

INSERTING<?php

$connection = new mysqli("localhost","ilyasgalacticos","","facebook");$connected = false;if(!$connection->connect_error){

$connected = true;}

if($connected){$query = $connection->query(“INSERT INTO users (id, login, full_name, password, age) VALUES (NULL,\”aziza\”, \” Aziza Kamet\”, \” qwerty\”, 19) “);

}

?>

Page 7: LECTURE 3 MYSQL Database. PHP MYSQL CONNECTION MySQL is a database system used on the web MySQL is a database system that runs on a server MySQL is ideal

UPDATING<?php

$connection = new mysqli("localhost","ilyasgalacticos","","facebook");$connected = false;if(!$connection->connect_error){

$connected = true;}

if($connected){$query = $connection->query(“

UPDATE users SET login = \“symbat\”, age = 18WHERE id = 3

”);}

?>

Page 8: LECTURE 3 MYSQL Database. PHP MYSQL CONNECTION MySQL is a database system used on the web MySQL is a database system that runs on a server MySQL is ideal

DELETING<?php

$connection = new mysqli("localhost","ilyasgalacticos","","facebook");$connected = false;if(!$connection->connect_error){ $connected = true;}

if($connected){$query = $connection->query(“DELETE FROM users WHERE id = 3”);}

?>

Page 9: LECTURE 3 MYSQL Database. PHP MYSQL CONNECTION MySQL is a database system used on the web MySQL is a database system that runs on a server MySQL is ideal

USING MYSQL in C9

In bash terminal(command line) to install mysql:mysql-ctl install

To start mysql:mysql-ctl start

To install phpmyadmin:phpmyadmin-ctl install