ModernPDO is a simple library for PHP v8.1

Overview

ModernPDO

ModernPDO is a simple library for PHP v8.1

Getting Started

Download the latest release, create the directory ModernPDO in your library directory, and drop ModernPDO/src/ into [lib-dir]/ModernPDO/.

Create the new ModernPDO instance:

$modernPDO = new \ModernPDO\ModernPDO(
        $type, // (mysql, etc.)
        $charset, // (utf8, utf8mb4, etc.)
        $host, // (localhost, etc.)
        $username, // user's name
        $password, // user's password
        $database, // database's name
);

Examples

Queries Examples

Source

// get all accounts
$modernPDO->exec("SELECT * FROM `account` WHERE 1");

Prepared

= ?", [1000])->fetchAll(); // get one account where name == ? $account = $modernPDO->query("SELECT * FROM `account` WHERE `name` = ?", ["StulE"])->fetch();">
// get all accounts where balance >= ? 
$accounts = $modernPDO->query("SELECT * FROM `account` WHERE `balance` >= ?", [1000])->fetchAll();
// get one account where name == ?
$account = $modernPDO->query("SELECT * FROM `account` WHERE `name` = ?", ["StulE"])->fetch();

CRUD Examples

DELETE

$modernPDO->delete($table)->where($col, $val)->execute();

INSERT

// long syntax
$modernPDO->insert($table)->values([$col1 => $val1, ...])->execute();
// short syntax
$modernPDO->insert($table, [$col1 => $val1, ...])->execute();

SELECT

// get all rows from $table
$modernPDO->select($table)->all();
// get rows from $table where $col == $val
$modernPDO->select($table)->where($col, $val)->one();
// get first row from $table by $order where $col == $val
$modernPDO->select($table)->where($col, $val)->firstBy($order);
// get last row from $table by $order where $col == $val
$modernPDO->select($table)->where($col, $val)->lastBy($order);

// long syntax
$modernPDO->select($table)->columns([$col1, $col2, ...])->all();
// short syntax
$modernPDO->select($table, [$col1, $col2, ...])->all();

UPDATE

// long syntax
$modernPDO->update($table)->set([$col1 => $val1, ...])->where($col, $val)->execute();
// short syntax
$modernPDO->update($table, [$col1 => $val1, ...])->where($col, $val)->execute();

Good Luck and Have Fun 😘

You might also like...
[virion] It Implements Simple Using Form Library System

SimpleForm [virion] It Implements Simple Using Form Library System How To Use First, declare the use statement. use AidenKR\SimpleForm\SimpleForm; use

A simple library to increase the power of your environment variables.
A simple library to increase the power of your environment variables.

Environment A simple library (with all methods covered by php unit tests) to increase the power of your environment variables, contribute with this pr

A simple library for management the DOM (XML, HTML) document.

A simple library for management the DOM (XML, HTML) document.

A simple library for dealing with docx word processed documents

WordCat Limited manipulation of docx word processed documents A simple php library for manipulation of docx word processed document; in particular the

Configure Magento 2 to send email using Google App, Gmail, Amazon Simple Email Service (SES), Microsoft Office365 and many other SMTP (Simple Mail Transfer Protocol) servers
Configure Magento 2 to send email using Google App, Gmail, Amazon Simple Email Service (SES), Microsoft Office365 and many other SMTP (Simple Mail Transfer Protocol) servers

Magento 2 SMTP Extension - Gmail, G Suite, Amazon SES, Office 365, Mailgun, SendGrid, Mandrill and other SMTP servers. For Magento 2.0.x, 2.1.x, 2.2.x

Easy to use utility functions for everyday PHP projects. This is a port of the Lodash JS library to PHP

Lodash-PHP Lodash-PHP is a port of the Lodash JS library to PHP. It is a set of easy to use utility functions for everyday PHP projects. Lodash-PHP tr

PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP language

php-text-analysis PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP l

php-echarts is a php library for the echarts 5.0.

php-echarts 一款支持Apache EChart5.0+图表的php开发库 优先ThinkPHP5/6的开发及测试。 Apache EChart5.0已经最新发布,在视觉效果、动画效果和大数据展示方面已经远超之前的版本; 故不考虑EChart5.0之前版本的兼容问题;建议直接尝试5.0+

Minimalist PHP frame for Core-Library, for Developing PHP application that gives you the full control of your application.

LazyPHP lightweight Pre-Made Frame for Core-library Install Run the below command in your terminal $ composer create-project ryzen/lazyphp my-first-pr

Releases(v1.1.0)
  • v1.1.0(Aug 10, 2022)

    • rewrote comments
    • wrote short syntax
    • wrote ModernPDO::(inTransaction, getLastId)
    • renamed ModernPDO::transaction -> ModernPDO::beginTransaction
    • wrote ModernPDO::exec(source query) and ModernPDO::query(prepared query)
    • wrote Statement.php for queries with functions (rowCount,fetch,fetchAll)
    Source code(tar.gz)
    Source code(zip)
Owner
Petya
Petya
Simple library that abstracts different metrics collectors. I find this necessary to have a consistent and simple metrics (functional) API that doesn't cause vendor lock-in.

Metrics Simple library that abstracts different metrics collectors. I find this necessary to have a consistent and simple metrics API that doesn't cau

Benjamin Eberlei 311 Nov 20, 2022
Columnar analytics for PHP - a pure PHP library to read and write simple columnar files in a performant way.

Columnar Analytics (in pure PHP) On GitHub: https://github.com/envoymediagroup/columna About the project What does it do? This library allows you to w

Envoy Media Group 2 Sep 26, 2022
Simple PHP Pages - A simple puristic PHP Website Boilerplate

Simple PHP Pages - A simple puristic PHP Website Boilerplate ?? Hey! This project provides simple and basic concepts for PHP pages. It includes ideas

SteamPixel 8 Sep 22, 2022
Sslurp is a simple library which aims to make properly dealing with SSL in PHP suck less.

Sslurp v1.0 by Evan Coury Introduction Dealing with SSL properly in PHP is a pain in the ass and completely insecure by default. Sslurp aims to make i

Evan Coury 65 Oct 14, 2022
Currency is a simple PHP library for current and historical currency exchange rates & crypto exchange rates. based on the free API exchangerate.host

Currency Currency is a simple PHP library for current and historical currency exchange rates & crypto exchange rates. based on the free API exchangera

Amr Shawky 19 Dec 12, 2022
A simple functional programming library for PHP

bingo-functional A simple functional programming library for PHP. Requirement(s) PHP 7 or higher Rationale PHP, a language not commonly associated wit

Lochemem Bruno Michael 52 Sep 28, 2022
A simple, standalone, modern PHP class inspector and mapper library, wrapping PHPs native reflection in a fluent interface

A simple, standalone, modern PHP class inspector and mapper library, wrapping PHPs native reflection in a fluent interface.

smpl 9 Sep 1, 2022
Simple async lowlevel ICMP (ping) messaging library built on top of React PHP

clue/icmp-react Simple async lowlevel ICMP (ping) messaging library built on top of react Usage Once clue/icmp-react is installed, you can run any of

Christian Lück 13 Jun 10, 2022
UMySQL is an extremely simple PHP library for communicating with MySQL databases with ease while keeping overhead to a bare minimum.

Uncomplicated MySQL UMySQL is an extremely simple PHP library for communicating with MySQL databases with ease while keeping overhead to a bare minimu

José Miguel Moreno 4 Oct 24, 2022
A simple wrapper around vlucas' PHP dotenv library for Kirby CMS.

kirby-phpdotenv A simple wrapper around vlucas' PHP dotenv library for Kirby CMS. Why? I've been using .env in my Kirby projects for a while, but I go

Steve Jamesson 5 Feb 6, 2020