Giter Site home page Giter Site logo

pdo2's Introduction

PDO2

Lightweight (5.6KB) PDO wrapper to accelerate database development.

Usage

$db = new PDO2($yourPdoInstance)

All PDO methods are still available directly, but the instance is augmented with six extra methods.

  1. execute(string $statement, array $input_parameters = []) : PDOStatement

    $stm = $db->execute("SELECT * FROM wat WHERE id = ?", [12]);
    // shortcut of
    $stm = $this->prepare("SELECT * FROM wat WHERE id = ?");
    $stm->execute([12]);
  2. select($table, $params = [], $extra = '', $values = []) : PDOStatement

    $db->select('actors');
    $db->select('actors', ['first_name' => 'Al']);
    $db->select('actors', ['age > ?' => 52]);
    $db->select('id,age,name from actors', ['age > ?' => 52]);
    // Associative array creates AND, list array creates OR.
    $db->select('actors', ['a' => 1, [['b' => 2], ['c' => 3]]])
    // SELECT * FROM actors WHERE a = ? AND ((b = ?) OR (c = ?))
  3. insert($table, array $params) : PDOStatement

    $db->insert('actors', ['first_name' => 'Humphrey', 'last_name' => 'Bogart', 'age' => 57]);
  4. update($table, array $params, array $where) : PDOStatement

    $db->update('actors', ['first_name' => 'Tommy'], ['id' => 3])
  5. delete($table, array $params) : PDOStatement

    $db->delete('actors', ['id' => 3]);
    $db->delete('actors', []); // empty where part cannot be omitted.
  6. count($table, array $params = null) : int

    $db->count('actors', ['first_name' => 'Tom'])

pdo2's People

Contributors

4d47 avatar

Watchers

 avatar  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.