PHPackages                             qrzysio/mysql-pdo-class - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. qrzysio/mysql-pdo-class

ActiveLibrary[Database &amp; ORM](/categories/database)

qrzysio/mysql-pdo-class
=======================

Just another PHP class to cope with MySQL via PDO.

v1.0.7(8y ago)11931MITPHPPHP &gt;=5.1.0

Since May 19Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Qrzysio/MySQL-PDO-class)[ Packagist](https://packagist.org/packages/qrzysio/mysql-pdo-class)[ RSS](/packages/qrzysio-mysql-pdo-class/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (9)Used By (0)

Intro
=====

[](#intro)

Just another PHP class to cope with MySQL via PDO.

### Installation

[](#installation)

Use composer:

```
composer require qrzysio/mysql-pdo-class

```

### Usage

[](#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

[](#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 'Something went wrong!';
  echo 'Details:';
  echo ''.$e->getMessage().'';
}

```

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 'Something went wrong!';
  echo 'Details:';
  echo ''.$e->getMessage().'';
}

```

### All methods

[](#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

[](#license)

This script was made by a bloger and published here:

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.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~102 days

Recently: every ~179 days

Total

8

Last Release

2978d ago

PHP version history (3 changes)v1.0.0PHP &gt;=5.3.0

v1.0.1PHP &gt;=5.5.0

v1.0.4PHP &gt;=5.1.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13356480?v=4)[Qrzysio](/maintainers/Qrzysio)[@Qrzysio](https://github.com/Qrzysio)

---

Top Contributors

[![Qrzysio](https://avatars.githubusercontent.com/u/13356480?v=4)](https://github.com/Qrzysio "Qrzysio (12 commits)")

---

Tags

phpmysqlpdoclass

### Embed Badge

![Health badge](/badges/qrzysio-mysql-pdo-class/health.svg)

```
[![Health](https://phpackages.com/badges/qrzysio-mysql-pdo-class/health.svg)](https://phpackages.com/packages/qrzysio-mysql-pdo-class)
```

###  Alternatives

[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k23.1k](/packages/clouddueling-mysqldump-php)[stefangabos/zebra_database

An advanced, compact and lightweight MySQL database wrapper library, built around PHP's MySQLi extension.

11712.4k](/packages/stefangabos-zebra-database)[eftec/pdoone

Minimaist procedural PDO wrapper library

1116.1k9](/packages/eftec-pdoone)[popphp/pop-db

Pop Db Component for Pop PHP Framework

1815.7k12](/packages/popphp-pop-db)[riverside/php-orm

PHP ORM micro-library and query builder

111.3k](/packages/riverside-php-orm)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
