GithubHelp home page GithubHelp logo

working-with-pdo's Introduction

Working Databases With PDO

This repo was created to learn how to persist data in relational database using PDO, an PHP extension many used on real world applications and by the PHP community.

Techs

  • PHP 8
  • Composer
  • Docker
  • SQLite and MySQL

What I learned?

  • How to connect by database with PDO object;
  • Use the exec() function to create table and insert data on table;
  • Use the query() function to execute SELECT queries;
  • Use the fetchAll() function to get the rows of data on table;
  • Use the fetch function to get the specific register on table and get all the registers no consumes memory doing a loop.
  • What's the SQL injection and how to do attack our application.
  • Adding params at string SQL is dangerous!
  • To solve this problem using Prepared Statement.
  • That prepared statement can even help the performance of application.
  • The difference between bindValue and bindParam to link parameters to prepared statement.
  • We can inform the data type passes through the PDO, using the third parameter of bindValue and bindParam: PDO::PARAM_INT.
  • The best practices and design patterns with object orientation.
  • The Entity pattern, and it's already been applied this project.
  • The Creation Method pattern that create a connection so don't need repeat this code on application.
  • The Repository pattern allow to extract the persistence logic for the specific class.
  • To abstract the repository implementation through an interface that can change implementation on future, case necessary.
  • The dependency injection concept and yours several advantages at development.
  • The importance of handle errors in our application.
  • By default, the PDO don't emit any error type.
  • To recover the error information by errorInfo method.
  • How to inform to PDO throw exceptions in error case.
  • Other attributes to configure the database connection using PDO.
  • To relate data on database in our object oriented application.
  • The Aggregate pattern where the objects access is controlled by others objects.
  • The N + 1 problem that is a big performance problem.
  • How to solve the N + 1 queries problem.
  • There are differences between the relational world (database) and the object oriented world (application).
  • The ORM's can help us to scan between these two worlds.
  • How it is easy to migrate database system using PDO.

working-with-pdo's People

Contributors

williamtome avatar

Watchers

 avatar

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.