PHPackages                             pajamasql/pajamasql - 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. pajamasql/pajamasql

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

pajamasql/pajamasql
===================

PHP SQL database layer

1.0.0(6y ago)0731MITPHPPHP &gt;=5.6.0CI failing

Since Jul 13Pushed 6y ago1 watchersCompare

[ Source](https://github.com/al-codepone/pajamaSQL)[ Packagist](https://packagist.org/packages/pajamasql/pajamasql)[ Docs](https://github.com/al-codepone/pajamaSQL)[ RSS](/packages/pajamasql-pajamasql/feed)WikiDiscussions master Synced today

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

pajamaSQL
=========

[](#pajamasql)

pajamaSQL is a PHP SQL database layer. It supports MySQL, PostgreSQL and SQLite.

Table of Contents
-----------------

[](#table-of-contents)

[Documentation](#documentation)
[Requirements](#requirements)
[Source Code](#source-code)
[Unit Tests](#unit-tests)
[Examples](#examples)
[Installation](#installation)
[Overview](#overview)
[MySQL](#mysql)
[PostgreSQL](#postgresql)
[SQLite](#sqlite)
[Models](#models)
[Error Handling](#error-handling)
[License](#license)

Documentation
-------------

[](#documentation)

This [README](https://github.com/al-codepone/pajamaSQL/blob/master/README.md)is currently the only documentation.

Requirements
------------

[](#requirements)

**PHP 5.6.0+ or 7+**; [Composer](https://getcomposer.org/); and at least one of the follow PHP vendor specific database extensions: [Mysqli](http://www.php.net/manual/en/book.mysqli.php), [PostgreSQL](http://www.php.net/manual/en/book.pgsql.php) and/or [SQLite3](http://www.php.net/manual/en/book.sqlite3.php). The unit tests need **PHP 7.2.0+**.

Source Code
-----------

[](#source-code)

This [project](https://github.com/al-codepone/pajamaSQL)and its [source code](https://github.com/al-codepone/pajamaSQL/tree/master/src/pjsql)are available on GitHub.

Unit Tests
----------

[](#unit-tests)

There are unit tests in the [tests](https://github.com/al-codepone/pajamaSQL/tree/master/tests) directory. You will need to edit the database credentials at the top of `MysqlTest.php` and `PgsqlTest.php`.

Examples
--------

[](#examples)

All the example code in this README is in the [examples](https://github.com/al-codepone/pajamaSQL/tree/master/examples)directory. The examples directory also contains additional examples that are not in this README. You need to run `composer install` in the examples directory before running any of the examples.

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

[](#installation)

Install using composer:

```
{
    "require": {
        "pajamasql/pajamasql": "1.0.0",
    }
}
```

Overview
--------

[](#overview)

pajamaSQL wraps [Mysqli](http://www.php.net/manual/en/book.mysqli.php), [PostgreSQL](http://www.php.net/manual/en/book.pgsql.php) and [SQLite3](http://www.php.net/manual/en/book.sqlite3.php)prepared statements. These are the available methods: `exec()`, `query()`, `rquery()`, `prepare()`, `bexec()`, `bquery()`, `brquery()`, `conn()`, `error()` and `esc()`. Basic usage looks like this:

```
$db->exec(
    'insert into foo values(?), (?)',
    'bar',
    'baz');

$data = $db->query(
    'select * from foo where rowid > ?',
    1);
```

There is also a model layer. A basic model looks like this:

```
