Download the PHP package qrzysio/mysql-pdo-class without Composer

On this page you can find all versions of the php package qrzysio/mysql-pdo-class. 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 mysql-pdo-class

Intro

Just another PHP class to cope with MySQL via PDO.

Installation

Use composer:

composer require qrzysio/mysql-pdo-class

Usage

require 'vendor/autoload.php';

$db = new Db();

$db->query('INSERT INTO mytable (FName, LName, Age, Gender) VALUES (:fname, :lname, :age, :gender)');
$db->bind(':fname', 'John');
$db->bind(':lname', 'Smith');
$db->bind(':age', '24');
$db->bind(':gender', 'male');
$db->exec();

echo $db->lastId();

*** Transactions ***

$db->beginTrans();

$db->query('INSERT INTO mytable (FName, LName, Age, Gender) VALUES (:fname, :lname, :age, :gender)');
$db->bind(':fname', 'Jenny');
$db->bind(':lname', 'Smith');
$db->bind(':age', '23');
$db->bind(':gender', 'female');
$db->exec();

$db->bind(':fname', 'Jilly');
$db->bind(':lname', 'Smith');
$db->bind(':age', '25');
$db->bind(':gender', 'female');
$db->exec();

echo $db->lastId();

$db->endTrans();

*** Select a single row ***

$db->query('SELECT FName, LName, Age, Gender FROM mytable WHERE FName = :fname');
$db->bind(':fname', 'Jenny');
$row = $db->single();

*** Select multiple rows ***

$db->query('SELECT FName, LName, Age, Gender FROM mytable WHERE LName = :lname');
$db->bind(':lname', 'Smith');
$rows = $db->fetch();

echo $db->numrows();

Try { } catch { } usage

It's very convenient to use try and catch blocks.

try {
  $db->query('INSERT INTO mytable (FName, LName, Age, Gender) VALUES (:fname, :lname, :age, :gender)');
  $db->bind(':fname', 'Jenny');
  $db->bind(':lname', 'Smith');
  $db->bind(':age', '23');
  $db->bind(':gender', 'female');
  $db->exec();
} catch (PDOException $e) {
  echo '<p>Something went wrong!</p>';
  echo '<p><strong>Details:</strong></p>';
  echo '<p>'.$e->getMessage().'</p>';  
}

Or more useful method.

try {

  // doing some operations
  ValidateFirst();

  // adding to database
  try {
    $db->query('INSERT INTO mytable (FName, LName, Age, Gender) VALUES (:fname, :lname, :age, :gender)');
    $db->bind(':fname', 'Jenny');
    $db->bind(':lname', 'Smith');
    $db->bind(':age', '23');
    $db->bind(':gender', 'female');
    $db->exec();    
  } catch (PDOException $e) {
    throw new Exception('We have an issue with this code!');    
  }

  // additional operations
  DoSomehing();

} catch (Exception $e) {
  echo '<p>Something went wrong!</p>';
  echo '<p><strong>Details:</strong></p>';
  echo '<p>'.$e->getMessage().'</p>';  
}

All methods

exec() - execute SQL query

fetch() - fetch all rows and returns an array

single() - fetch only one row as an array

numrows() - returns number of rows affected or counted

lastId() - last inserted ID

cancel() - rollback the operation

debug() - returns debugDumpParams() method from PDO

beginTrans() - begins a transaction

endTrans() - ends a transaction  

License

This script was made by a bloger and published here: http://culttt.com/2012/10/01/roll-your-own-pdo-php-class/

There is no info about license, so I believe it's MIT. I did some small changes in the code and perhaps will do more in the future. According to the former author, license of this script is MIT.


All versions of mysql-pdo-class with dependencies

PHP Build Version
Package Version
Requires php Version >=5.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 qrzysio/mysql-pdo-class contains the following files

Loading the files please wait ....