PHPackages                             simpl/sql - 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. simpl/sql

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

simpl/sql
=========

A dead-simple layer on top of PDO to make PDO setup and querying simpler

v1.3.0(5y ago)01181MITPHPPHP &gt;=5.1.0

Since Oct 12Pushed 5y ago1 watchersCompare

[ Source](https://github.com/simpl-php/sql)[ Packagist](https://packagist.org/packages/simpl/sql)[ Docs](https://github.com/simpl-php/sql)[ RSS](/packages/simpl-sql/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (3)Versions (5)Used By (1)

Simple/SQL
==========

[](#simplesql)

[![Build Status](https://camo.githubusercontent.com/6dc2cbeedd376981d6f7138d94187f5ee77ced2e6d8e23b9c971ee58999361cb/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f73696d706c2d7068702f73716c2e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/simpl-php/sql)

A dead-simple layer on top of PDO to make PDO setup and querying simpler
------------------------------------------------------------------------

[](#a-dead-simple-layer-on-top-of-pdo-to-make-pdo-setup-and-querying-simpler)

This component makes it easy to make and execute SQL statements with PDO.

You can run parameterized queries in a single step instead of doing separate prepare and execute statements.

This will automatically convert your query to a prepared statement with parameterized queries to prevent nasty SQL injection attacks.

Installation
------------

[](#installation)

```
composer require simpl/sql
```

Usage
-----

[](#usage)

### Connecting to the database.

[](#connecting-to-the-database)

#### Basic connection

[](#basic-connection)

```
$db = new \Simpl\SQL('localhost', 'your-db-name', 'your-username', 'your-password');
```

#### Connection with configuration array.

[](#connection-with-configuration-array)

```
$config = [
    'prefix' => 'mysql',
    'host' => 'localhost',
    'port' => 3306,
    'dbname' => 'your-db-name',
    'username' => 'your-username',
    'password' => 'your-password'
];
$db = new \Simpl\SQL($config);
```

### Running a SELECT query with parameters.

[](#running-a-select-query-with-parameters)

```
$res = $db->query('select * from test where foo = ? or bar = ?', [$foo, $bar]);
```

> Since this is just a wrapper around PDO, you'll get back a `\PDOStatement` object you can then operate on as you normally would.

See  for full documentation.

Coding Standards
----------------

[](#coding-standards)

This library uses [PHP\_CodeSniffer](http://www.squizlabs.com/php-codesniffer) to ensure coding standards are followed.

I have adopted the [PHP FIG PSR-2 Coding Standard](http://www.php-fig.org/psr/psr-2/) EXCEPT for the tabs vs spaces for indentation rule. PSR-2 says 4 spaces. I use tabs. No discussion.

To support indenting with tabs, I've defined a custom PSR-2 ruleset that extends the standard [PSR-2 ruleset used by PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/PSR2/ruleset.xml). You can find this ruleset in the root of this project at PSR2Tabs.xml

### Codesniffer

[](#codesniffer)

```
composer codensiffer
```

### Codefixer

[](#codefixer)

```
composer codefixer
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~4 days

Total

4

Last Release

2030d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1cda8a02682a999e89bc2443c6c169b1dc9228cc4709d0b5fad642dc2a151141?d=identicon)[joshmoody](/maintainers/joshmoody)

---

Top Contributors

[![volnix](https://avatars.githubusercontent.com/u/1538220?v=4)](https://github.com/volnix "volnix (2 commits)")[![joshmoody](https://avatars.githubusercontent.com/u/1504862?v=4)](https://github.com/joshmoody "joshmoody (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/simpl-sql/health.svg)

```
[![Health](https://phpackages.com/badges/simpl-sql/health.svg)](https://phpackages.com/packages/simpl-sql)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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