1645453589
In diesem Tutorial zeigen wir Ihnen, wie Sie mit PHP eine MySQL-Datenbanktabelle mithilfe der PDO-API erstellen.
Die folgenden Schritte zeigen Ihnen, wie Sie eine neue Tabelle in einer Datenbank erstellen:
Wir erstellen eine neue Tabelle mit dem Namen tasks
in der Beispieldatenbank mit dem folgenden SQL-Skript:
CREATE TABLE IF NOT EXISTS tasks (
task_id INT AUTO_INCREMENT PRIMARY KEY,
subject VARCHAR (255) DEFAULT NULL,
start_date DATE DEFAULT NULL,
end_date DATE DEFAULT NULL,
description VARCHAR (400) DEFAULT NULL
);
Zuerst erstellen wir eine Klasse namens CreateTableDemo
mit DB-Konfigurationsparametern. Im Konstruktor der CreateTableDemo
Klasse öffnen wir eine Verbindung zur Beispieldatenbank, indem wir ein neues PDO-Objekt instanziieren.
<?php
/**
* PHP MySQL Create Table Demo
*/
class CreateTableDemo {
/**
* database host
*/
const DB_HOST = 'localhost';
/**
* database name
*/
const DB_NAME = 'classicmodels';
/**
* database user
*/
const DB_USER = 'root';
/*
* database password
*/
const DB_PASSWORD = '';
/**
*
* @var type
*/
private $pdo = null;
/**
* Open the database connection
*/
public function __construct() {
// open database connection
$conStr = sprintf("mysql:host=%s;dbname=%s", self::DB_HOST, self::DB_NAME);
try {
$this->pdo = new PDO($conStr, self::DB_USER, self::DB_PASSWORD);
} catch (PDOException $e) {
echo $e->getMessage();
}
}
//...
}
Als nächstes schließen wir im Destruktor der CreateTabledemo
Klasse die Datenbankverbindung, indem wir ihr den null
Wert zuweisen.
/**
* close the database connection
*/
public function __destruct() {
// close the database connection
$this->pdo = null;
}
Definieren Sie dann die createTaskTable()
Methode zum Erstellen der tasks
Tabelle:
/**
* create the tasks table
* @return boolean returns true on success or false on failure
*/
public function createTaskTable() {
$sql = <<<EOSQL
CREATE TABLE IF NOT EXISTS tasks (
task_id INT AUTO_INCREMENT PRIMARY KEY,
subject VARCHAR (255) DEFAULT NULL,
start_date DATE DEFAULT NULL,
end_date DATE DEFAULT NULL,
description VARCHAR (400) DEFAULT NULL
);
EOSQL;
return $this->pdo->exec($sql);
}
Um eine SQL-Anweisung auszuführen, rufen Sie die exec()
Methode des PDO-Objekts auf. Danach können Sie eine Instanz der Klasse erstellen und die Methode CreateTableDemo
aufrufen .createTaskTable()
// create the tasks table
$obj = new CreateTableDemo();
$obj->createTaskTable();
Schließlich können Sie die Beispieldatenbank überprüfen, classicmodels
um festzustellen, ob die tasks
Tabelle erstellt wurde.
Sie können die PHP-Skriptdatei über den folgenden Link herunterladen:
Laden Sie den PHP MySQL-Quellcode zum Erstellen von Tabellen herunter
In diesem Tutorial haben wir Ihnen Schritt für Schritt gezeigt, wie Sie mit dem PDO-Objekt eine Tabelle in der MySQL-Datenbank erstellen.
1595905879
HTML to Markdown
MySQL is the all-time number one open source database in the world, and a staple in RDBMS space. DigitalOcean is quickly building its reputation as the developers cloud by providing an affordable, flexible and easy to use cloud platform for developers to work with. MySQL on DigitalOcean is a natural fit, but what’s the best way to deploy your cloud database? In this post, we are going to compare the top two providers, DigitalOcean Managed Databases for MySQL vs. ScaleGrid MySQL hosting on DigitalOcean.
At a glance – TLDR
ScaleGrid Blog - At a glance overview - 1st pointCompare Throughput
ScaleGrid averages almost 40% higher throughput over DigitalOcean for MySQL, with up to 46% higher throughput in write-intensive workloads. Read now
ScaleGrid Blog - At a glance overview - 2nd pointCompare Latency
On average, ScaleGrid achieves almost 30% lower latency over DigitalOcean for the same deployment configurations. Read now
ScaleGrid Blog - At a glance overview - 3rd pointCompare Pricing
ScaleGrid provides 30% more storage on average vs. DigitalOcean for MySQL at the same affordable price. Read now
MySQL DigitalOcean Performance Benchmark
In this benchmark, we compare equivalent plan sizes between ScaleGrid MySQL on DigitalOcean and DigitalOcean Managed Databases for MySQL. We are going to use a common, popular plan size using the below configurations for this performance benchmark:
Comparison Overview
ScaleGridDigitalOceanInstance TypeMedium: 4 vCPUsMedium: 4 vCPUsMySQL Version8.0.208.0.20RAM8GB8GBSSD140GB115GBDeployment TypeStandaloneStandaloneRegionSF03SF03SupportIncludedBusiness-level support included with account sizes over $500/monthMonthly Price$120$120
As you can see above, ScaleGrid and DigitalOcean offer the same plan configurations across this plan size, apart from SSD where ScaleGrid provides over 20% more storage for the same price.
To ensure the most accurate results in our performance tests, we run the benchmark four times for each comparison to find the average performance across throughput and latency over read-intensive workloads, balanced workloads, and write-intensive workloads.
Throughput
In this benchmark, we measure MySQL throughput in terms of queries per second (QPS) to measure our query efficiency. To quickly summarize the results, we display read-intensive, write-intensive and balanced workload averages below for 150 threads for ScaleGrid vs. DigitalOcean MySQL:
ScaleGrid MySQL vs DigitalOcean Managed Databases - Throughput Performance Graph
For the common 150 thread comparison, ScaleGrid averages almost 40% higher throughput over DigitalOcean for MySQL, with up to 46% higher throughput in write-intensive workloads.
#cloud #database #developer #digital ocean #mysql #performance #scalegrid #95th percentile latency #balanced workloads #developers cloud #digitalocean droplet #digitalocean managed databases #digitalocean performance #digitalocean pricing #higher throughput #latency benchmark #lower latency #mysql benchmark setup #mysql client threads #mysql configuration #mysql digitalocean #mysql latency #mysql on digitalocean #mysql throughput #performance benchmark #queries per second #read-intensive #scalegrid mysql #scalegrid vs. digitalocean #throughput benchmark #write-intensive
1597487472
Here, i will show you how to populate country state city in dropdown list in php mysql using ajax.
You can use the below given steps to retrieve and display country, state and city in dropdown list in PHP MySQL database using jQuery ajax onchange:
https://www.tutsmake.com/country-state-city-database-in-mysql-php-ajax/
#country state city drop down list in php mysql #country state city database in mysql php #country state city drop down list using ajax in php #country state city drop down list using ajax in php demo #country state city drop down list using ajax php example #country state city drop down list in php mysql ajax
1599478097
simple search code in php with demo. Here, i will show you how to create live search in PHP MySQL using jQuery ajax from database.
Use the following simple steps and create ajax live search PHP MySQL from database:
https://www.tutsmake.com/ajax-php-mysql-search-example/
#live search in php mysql ajax with examples #simple search code in php with demo #php mysql search form example #php code for search data from database #source code search php
1597820991
Looking to develop a PHP based website from scratch or revamp your existing website?
HourlyDeveloper.io has always been an industry leader for companies and business owners looking to hire PHP web developer. By choosing to Hire PHP Developer from our company, you can always expect the best results. Our PHP services and solutions are always flexible which means that no matter the nature of your project, you can always count on us for getting the best PHP expertise.
Consult with our experts: https://bit.ly/3aEGxPy
#hire php developer #php developer #php development company #php development services #php development #php
1599275499
php code for updating data in mysql database. Here, i will show you how to fetch and update data from mysql in php.
https://www.tutsmake.com/php-code-for-update-data-in-mysql-database/
#how to edit data in php using form #how to update data in php using form mysqli #how to fetch and update data from database in php #php code for updating data in mysql database #php #update