Giter Site home page Giter Site logo

tomwright / extendedpdo Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 42 KB

A simple PDO Wrapper and Query Builder made to shorten the time it takes to get results from basic SQL queries.

PHP 100.00%
database database-access php php-7 mysql pdo pdo-wrapper singleton query-builder sql

extendedpdo's Introduction

Extended PDO

Build Status Latest Stable Version Total Downloads Monthly Downloads Daily Downloads License

Installation

composer install tomwright/extended-pdo

Connecting

ExtendedPDO implements the singleton design pattern using tomwright/singleton. For more information on how the following code works, see the documentation.

$db = ExtendedPDO::createConnection($dsn, $username, $password, 'my-main-db');
$db2 = ExtendedPDO::getInstance('my-main-db');

var_dump($db === $db2) // TRUE

Usage

// Returns an array of records
$db->queryAll('SELECT * FROM users WHERE username = :username', [':username' => 'Tom']);

// Returns the first record
$db->queryRow('SELECT * FROM users WHERE username = :username LIMIT 1', [':username' => 'Tom']);

Query Return Types

You can set the return type of the dbQuery(), queryAll() and queryRow() methods using $db->setReturnType($x) where $x is the return type you'd like to use.

Available return types are as follows:

  • ExtendedPDO::RETURN_TYPE_OBJECT - Your results will be returned as objects
  • ExtendedPDO::RETURN_TYPE_ASSOC - Your results will be returned as associative arrays
  • ExtendedPDO::RETURN_TYPE_STMT - The statement object will be returned directly

You can also set a return type of \PDO::FETCH_ASSOC for example and it will override any of the above. This makes all of the standard PDO fetch types usable.

Query Builder

ExtendedPDO also comes with it's own Query Builder.

extendedpdo's People

Contributors

tomwright avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

extendedpdo's Issues

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.