2017 © Pedro Peláez
 

library dbwrapper

Simple MySQL db wrapper functions using PDO

image

majenkotech/dbwrapper

Simple MySQL db wrapper functions using PDO

  • Thursday, January 18, 2018
  • by majenkotech
  • Repository
  • 1 Watchers
  • 0 Stars
  • 31 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Simple PDO MySQL Wrapper Class

This is a simple class for providing a simple API to the PDO MySQL database driver., (*1)

It relies on all tables in your database having a column called id which is typically a serial type (bigint(20) unsigned auto_increment). This column is used to select individual records within a table., (*2)

Usage

  1. Create an object:, (*3)

    $db = new \Majenkotech\DB("username", "password", "hostname", "database");, (*4)

  2. Execute a query with optional embedded arguments:, (*5)

    $q = $db->query("SELECT name,size FROM something WHERE foo=:bar AND baz=:fod", array( "bar" => 23, "fod" => "beep" ) );, (*6)

  3. Use $db->nextRecord($q) to get successive record objects:, (*7)

    while ($r = $db->nextRecord($q)) { print "$r->name is $r->size\n"; }, (*8)

Other useful functions

  • Insert a new record into a table:, (*9)

    $id = $db->insert("tablename", array( "field1" => "value", "field2" => value, ... etc ... ));, (*10)

  • Get ID of last inserted record:, (*11)

    $id = $db->id();, (*12)

  • Update a record in a table:, (*13)

    $db->update("table", $id, array( "field1" => "value", "field2" => value, ... etc ... ));, (*14)

  • Select a record by ID:, (*15)

    $r = $db->select("tablename", $id);, (*16)

  • Set a single value in a record in a table:, (*17)

    $db->set("table", $id, "field", "value");, (*18)

The Versions

18/01 2018

dev-master

9999999-dev

Simple MySQL db wrapper functions using PDO

  Sources   Download

BSD-3-Clause

by Matt Jenkins

18/01 2018

v0.2.1

0.2.1.0

Simple MySQL db wrapper functions using PDO

  Sources   Download

BSD3

by Matt Jenkins

05/01 2018

v0.2.0

0.2.0.0

Simple MySQL db wrapper functions using PDO

  Sources   Download

BSD3

by Matt Jenkins

04/01 2018

v0.1.0

0.1.0.0

Simple MySQL db wrapper functions using PDO

  Sources   Download

BSD3

by Matt Jenkins

04/01 2018

v0.0.5

0.0.5.0

Simple MySQL db wrapper functions using PDO

  Sources   Download

BSD3

by Matt Jenkins

04/01 2018

v0.0.4

0.0.4.0

Simple MySQL db wrapper functions using PDO

  Sources   Download

BSD3

by Matt Jenkins

04/01 2018

v0.0.3

0.0.3.0

Simple MySQL db wrapper functions using PDO

  Sources   Download

BSD3

by Matt Jenkins

04/01 2018

v0.0.2

0.0.2.0

Simple MySQL db wrapper functions using PDO

  Sources   Download

BSD3

by Matt Jenkins

04/01 2018

v0.0.1

0.0.1.0

Simple MySQL db wrapper functions using PDO

  Sources   Download

by Matt Jenkins