Download the PHP package ezrarieben/pdo-wrapper-singleton without Composer

On this page you can find all versions of the php package ezrarieben/pdo-wrapper-singleton. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pdo-wrapper-singleton

pdo-wrapper-singleton

A wrapper class written in PHP for PDO MySQL DB connections following the singleton pattern.

License: MIT

Table of contents

Installation

To use the wrapper in your project, add it as a dependency via composer:

Basic example

Usage

Importing wrapper class

For ease of use it is recommended to import the wrapper class with use

Setting up DB connection

In order to use the wrapper class Database the connection parameters need to be set first.

There are certain required parameters that need to be set in order for the PDO connection to work.
(See "Required" column in available parameters table for required parameters).

Minimal setup example

Extensive setup example

Available parameters

Description Setter function Parameters Required
DB server host setHost() string $host YES
User setUser() string $user YES
Password setPassword() string $password YES
DB server host setPort() int $port
Database name setDbName() ?string $dbName
PDO attributes setPdoAttributes() array $attributes

DB interaction

Using PDO functions

All PDO functions can be accessed statically through the Database class:

Prepared statements

The Database class has a shortcut function for prepared statements called run():

Parameters Description Required
string $query SQL query to execute YES
array $params parameters to pass to query

The function returns a PDOStatement object if preperation and execution of query was successfull.
If preperation or execution of query failed the function will throw a PDOException or return false depending on the currently set PDO error mode.
(see: Error handling for more info)

Example

Example with named parameters

Error handling

PDO's error mode is set to ERRMODE_EXCEPTION by default.
Error handling can therefore be done through try and catch blocks.

When switching to a different error mode you will need to handle errors through booleans.

NOTE: Error handling using booleans is only supported if you change PDO's error mode.


All versions of pdo-wrapper-singleton with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ezrarieben/pdo-wrapper-singleton contains the following files

Loading the files please wait ....