lecture 3 mysql database
Download
Report
Transcript lecture 3 mysql database
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 for both small and large applications
MySQL is very fast, reliable, and easy to use
MySQL uses standard SQL
MySQL compiles on a number of platforms
MySQL is free to download and use
MySQL is developed, distributed, and supported by Oracle Corporation
MySQL is named after co-founder Monty Widenius's daughter: My
PHP + MySQL Database System
• PHP combined with MySQL are cross-platform
(you can develop in Windows and serve on a
Unix platform)
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>";
}
}
?>
RESULT:
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) “);
}
?>
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 = 18
WHERE id = 3
”);
}
?>
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
”);
}
?>
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