So verwenden Sie PHP zum Erstellen einer MySQL-Datenbanktabelle

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:

  • Öffnen Sie eine Datenbankverbindung zum MySQL-Datenbankserver.
  • Führen Sie die CREATE TABLE-Anweisung aus, um neue Tabellen zu erstellen.

PHP MySQL: Tabellenbeispiel erstellen

Wir erstellen eine neue Tabelle mit dem Namen tasksin 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 CreateTableDemomit DB-Konfigurationsparametern. Im Konstruktor der CreateTableDemoKlasse ö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 CreateTabledemoKlasse die Datenbankverbindung, indem wir ihr den  nullWert zuweisen.

 /**
     * close the database connection
     */
    public function __destruct() {
        // close the database connection
        $this->pdo = null;
    }

Definieren Sie dann die createTaskTable()Methode zum Erstellen der tasksTabelle:

/**
     * 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 CreateTableDemoaufrufen .createTaskTable()

// create the tasks table
$obj = new CreateTableDemo();
$obj->createTaskTable();

Schließlich können Sie die Beispieldatenbank überprüfen, classicmodelsum festzustellen, ob die tasksTabelle erstellt wurde.

php mysql tabelle erstellen

PHP MySQL Tabelle erstellen: Aufgaben

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.

What is GEEK

Buddha Community

Joe  Hoppe

Joe Hoppe

1595905879

Best MySQL DigitalOcean Performance – ScaleGrid vs. DigitalOcean Managed Databases

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

I am Developer

1597487472

Country State City Dropdown list in PHP MySQL PHP

Here, i will show you how to populate country state city in dropdown list in php mysql using ajax.

Country State City Dropdown List in PHP 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:

  • Step 1: Create Country State City Table
  • Step 2: Insert Data Into Country State City Table
  • Step 3: Create DB Connection PHP File
  • Step 4: Create Html Form For Display Country, State and City Dropdown
  • Step 5: Get States by Selected Country from MySQL Database in Dropdown List using PHP script
  • Step 6: Get Cities by Selected State from MySQL Database in DropDown List using PHP script

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

I am Developer

1599478097

Ajax Live Data Search using jQuery PHP MySQL

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.

PHP MySQL Ajax Live Search

Use the following simple steps and create ajax live search PHP MySQL from database:

  1. Connecting Database File
  2. Create an ajax live search form PHP
  3. Create a PHP Script for Live Search From DB using Ajax

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

Hire PHP Developer

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

I am Developer

1599275499

PHP Code for Update Data in MySQL Database - Tuts Make

php code for updating data in mysql database. Here, i will show you how to fetch and update data from mysql in php.

PHP Code for retrieve and update data form mysql database

  1. Step 1 - Connect to MySQL database
  2. Step 2 - Fetch data from the database
  3. Step 3 - Update data from database

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