Git Product home page Git Product logo

mariadb-developers / php-pdo-quickstart Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 1.0 350 KB

This repository contains a simple web application that demonstrates how to quickly connect to and communicate with a MariaDB database using PHP and PDO (PHP Data Objects).

License: MIT License

PHP 78.87% CSS 21.13%
mariadb mariadb-database php-mysql php-pdo php-pdo-mysql php-mariadb mariadb-php pdo pdo-mariadb pdo-mysql quickstart php-driver

php-pdo-quickstart's Introduction

PHP with PDO (PHP Data Objects) Quickstart

This repository contains a simple web application that demonstrates how to quickly connect to and communicate with a MariaDB database using PHP and PDO (PHP Data Objects).

โš ๏ธ Interested in using MariaDB and PHP with mysqli? Check out the quickstart here!

Getting Started

The application in this repository demonstrates how to:

  • Connect to a MariaDB database using PDO (PHP Data Objects)
  • Execute queries (SELECT, UPDATE, INSERT and DELETE) to manage contact data (like a digital rolodex)
  • Use prepared statements

Prepare the database

The application relies on a single database (rolodex) that contains a single table (contacts). You can find the necessary SQL for setting up the environment in schema.sql.

Run the application

After you've pulled down this repository, follow these steps to get the app up and running:

  1. Update the database configuration settings in src/config.php (which is used across the app) to point to your MariaDB database.

    Example configuration:

    $dsn = "mysql:host=127.0.0.1;dbname=rolodex;charset=utf8mb4";
    
    $options = [
    PDO::ATTR_EMULATE_PREPARES   => false, // Disable emulation mode for "real" prepared statements
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION, // Disable errors in the form of exceptions
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, // Make the default fetch be an associative array
    ];
    
    $pdo = new PDO($dsn, "app_user", "Password123!", $options);
  2. Within the src directory, run the application using the built-in web server.

    $ php -S localhost:5000

Helpful Resources

Support and Contribution

Please feel free to submit PR's, issues or requests to this project directly.

If you have any other questions, comments, or looking for more information on MariaDB please check out:

Or reach out to us directly via:

License

License

php-pdo-quickstart's People

Contributors

rhedgpeth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

makarenco78

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.