GithubHelp home page GithubHelp logo

protocollive / phplivedb Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 374 KB

Home Page: https://protocollive.github.io/PhpLiveDbDocs/en

License: MIT License

PHP 100.00%
pdo php81 pdo-mysql pdo-sqlite

phplivedb's Introduction

Why PhpLiveDB?

Using large querys with PDO, you have a lot of fields and placeholders... Using insert with ordered placeholders, it's worse, because you don't know which placeholder is which field...

$pdo->prepare("
  insert into users('id', 'name', 'email', 'password', 'address', 'country', 'zipcode', 'telephone', 'gender', 'register_date', 'last_login', 'last_pass_change')
  values(?,?,?,?,?,?,?,?,?,?,?,?)
");

That's a simple example. We know there are a lot of bigger queries out there... What if I need to add a new field? Just add the field name and one more placeholder. What if PDO throws an error saying different placeholder fields and numbers? I'd have to count them one by one...

Named placeholders help with this. Okay, but that's a lot of lines to write and manage... This library helps with that:

$db->Insert('users')
->FieldAdd('id', $id, Types::Int)
->FieldAdd('name', $name, Types::Str)
->FieldAdd('email', $email, Types::Str)
->FieldAdd('password', $password, Types::Str)
->FieldAdd('address', $address, Types::Str)
->FieldAdd('country', $country, Types::Str)
->FieldAdd('zipcode', $zipcode, Types::Str)
->FieldAdd('telephone', $telephone, Types::Str)
->FieldAdd('gender', $gender, Types::Str)
->FieldAdd('register_date', $register_date, Types::Str)
->FieldAdd('last_login', $last_login, Types::Int)
->FieldAdd('last_pass_change', $last_pass_change, Types::Int)
->Run();

This was the initial idea of the library that was expanded according to my needs and today it is a very complete library (if not, feedbacks are welcome) that I use in my daily life and share with the world.

For the documentation, click here.

Install

  • Download the library in zip format and use the src folder content;
  • Via Composer with composer install protocollive/phplivedb;

phplivedb's People

Contributors

protocollive avatar

Stargazers

 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.