2017 © Pedro Peláez
 

library thin-pdo

image

fulldecent/thin-pdo

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 9 Versions
  • 6 % Grown

The README.md


PHP PDO Wrapper Class

A minimal extension for PHP's PDO class designed to make running SQL statements easier., (*1)

Download the latest release, (*2)

Project Overview

This project provides a minimal extension for PHP's PDO (PHP Data Objects) class designed for ease-of-use and saving development time/effort. This is achived by providing methods - delete, insert, select, and update - for quickly building common SQL statements, handling exceptions when SQL errors are produced, and automatically returning results/number of affected rows for the appropriate SQL statement types., (*3)

System Requirements

  • PHP 5.5+ (any current PHP version, see https://secure.php.net/supported-versions.php), (*4)

  • PDO Extension, (*5)

  • Appropriate PDO Driver(s) - PDO_SQLITE, PDO_MYSQL, PDO_PGSQL, (*6)

  • Only MySQL, SQLite, and PostgreSQL database types are currently supported., (*7)

db Class Methods

Below you will find a detailed explanation along with code samples for each of the 6 methods included in the db class., (*8)

constructor


More information can be found on how to set the dsn parameter by following the links provided below., (*9)

delete

delete("mytable", "Age  $lname
)
$db->delete("mytable", "LName = :lname", $bind);
?>

If no SQL errors are produced, this method will return the number of rows affected by the DELETE statement., (*13)

insert

 "John",
    "LName" => "Doe",
    "Age" => 26,
    "Gender" => "male"
);
$db->insert("mytable", $insert);
?>

If no SQL errors are produced, this method will return the number of rows affected by the INSERT statement., (*14)

See also: $db->lastInsertId(); which is inherited from PDO., (*15)

run

run($sql);

//SQLite
$sql = run($sql);
?>

This method is used to run free-form SQL statements that can't be handled by the included delete, insert, select, or update methods. If no SQL errors are produced, this method will return the number of affected rows for DELETE, INSERT, and UPDATE statements, or an associate array of results for SELECT, DESCRIBE, and PRAGMA statements., (*16)

select

select("mytable");

//SELECT #2
$results = $db->select("mytable", "Gender = 'male'");

//SELECT #3 w/Prepared Statement
$search = "J";
$bind = array(
    ":search" => "%$search"
);
$results = $db->select("mytable", "FName LIKE :search", $bind);
?>

setErrorCallbackFunction

setErrorCallbackFunction("myErrorHandler");
/*
Text Version
$db->setErrorCallbackFunction("myErrorHandler", "text");

Internal/Built-In PHP Function
$db->setErrorCallbackFunction("echo");
*/
$results = $db->select("mynonexistingtable");
?>

When a SQL error occurs, this project will send a formatted (html or text) error message to a callback function specified through the setErrorCallbackFunction method. The callback function's name should be supplied as a string without parenthesis. As you can see in the examples provided above, you can specify an internal/built-in PHP function or a custom function you've created., (*17)

If no SQL errors are produced, this method will return an associative array of results., (*18)

update

 "Jane",
    "Gender" => "female"
);
$db->update("mytable", $update, "FName = 'John'");

//Update #2 w/Prepared Statement
$update = array(
    "Age" => 24
);
$fname = "Jane";
$lname = "Doe";
$bind = array(
    ":fname" => $fname,
    ":lname" => $lname
);
$db->update("mytable", $update, "FName = :fname AND LName = :lname", $bind);
?>

If no SQL errors are produced, this method will return the number of rows affected by the UPDATE statement., (*19)

The Versions

30/07 2018

dev-wiki

dev-wiki

  Sources   Download

01/04 2018

1.0.2

1.0.2.0

  Sources   Download

01/04 2018

1.0.3

1.0.3.0

  Sources   Download

01/04 2018

1.0.4

1.0.4.0

  Sources   Download

01/04 2018

1.1.0

1.1.0.0

  Sources   Download

01/12 2016

dev-master

9999999-dev http://github.com/fulldecent/pdo-wrapper

A minimal extension for PHP's PDO class designed to make running SQL statements easier

  Sources   Download

MIT

The Requires

  • php >=5.5

 

database postgresql wrapper pdo mysql oracle

29/11 2016

1.2.2

1.2.2.0 http://github.com/fulldecent/pdo-wrapper

A minimal extension for PHP's PDO class designed to make running SQL statements easier

  Sources   Download

MIT

The Requires

  • php >=5.5

 

database postgresql wrapper pdo mysql oracle

23/05 2016

1.2.1

1.2.1.0 http://github.com/fulldecent/pdo-wrapper

A minimal extension for PHP's PDO class designed to make running SQL statements easier

  Sources   Download

MIT

The Requires

  • php >=5.5

 

database postgresql wrapper pdo mysql oracle

16/05 2016

1.2.0

1.2.0.0 http://github.com/fulldecent/pdo-wrapper

A minimal extension for PHP's PDO class designed to make running SQL statements easier

  Sources   Download

MIT

The Requires

  • php >=5.5

 

database postgresql wrapper pdo mysql oracle