PHPackages                             bistro/data - 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. bistro/data

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

bistro/data
===========

A collection of classes to make data management easy

0.7.0(12y ago)1431MITPHPPHP &gt;=5.3

Since Jul 6Pushed 12y ago1 watchersCompare

[ Source](https://github.com/Bistro/Data)[ Packagist](https://packagist.org/packages/bistro/data)[ RSS](/packages/bistro-data/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (8)Used By (1)

Bistro: Data
============

[](#bistro-data)

The Bistro data package contains a lot of useful classes to help you manage your data.

Heavy Development!!!
--------------------

[](#heavy-development)

Everything below may or may not be correct. I'm working on merging a few different repos I have created into this larger package, so please be patient while I get things in order.

---

A MySQL query builder engine for PDO which requires PHP 5.3.

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

[](#installation)

The easiest way to install Peyote is by adding this line to your [composer.json](http://getcomposer.org/) file.

```
"require":{
	"davewid/peyote": "0.6.*"
},
```

Optionally you can download the source of this repo and move over the `classes`folder.

Standards
---------

[](#standards)

Peyote follows both the [PSR-0](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md)and [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md)standards.

There isn't an autoloader included with the library though so you will need to set that up yourself. If you use [Composer](http://getcomposer.org/) to install the dependency *(highly recommended)* then you won't have to worry about anything as Composer will take care of it all.

Example
-------

[](#example)

I'll start out with a full example on how to use the library and break it down as we go along.

```
// Create a PDO instance
$pdo = new PDO($dsn, $user, $password);

// Create a SELECT query
$query = new \Peyote\Select('user');
$query->where('user_id', '=', 1);

// Build the PDOStatement
$statement = $pdo->prepare($query->compile());

// Run the query
$statement->execute($query->getParams());

// Fetch results
$results = $statement->fetchAll();
```

#### Why the `getParams()` call?

[](#why-the-getparams-call)

Keeping your queries safe from SQL injection is out of the scope of this library so Peyote uses ? placeholders instead and keeps track of all the data you enter.

If you would echo out $query-&gt;compile() you would see this.

```
SELECT * FROM user WHERE user_id = ?
```

At this point `getParams()` will return an array holding the values you passed in, *(in this case, 1)*.

PDO will handle the placeholder replacement during `execute()` keeping you a lot safer from SQL injection.

Select
------

[](#select)

```
$query = new \Peyote\Select('user');
$query->where('user_id', '=', 1);

echo $query->compile();
// output: SELECT * FROM user WHERE user_id = ?

```

Insert
------

[](#insert)

```
$data = array(
	'email' => "testing@foo.com",
	'password' => "youllneverguess"
);

$query = new \Peyote\Insert('user');
$query->columns(array_keys($data))->values(array_values($data));

echo $query->compile();
// output: INSERT INTO user (email, password) VALUES (?, ?)
```

Update
------

[](#update)

```
$data = array(
	'password' => "iguesssomebodyguessed"
);

$query = new \Peyote\Update('user');
$query->set($data)->where('user_id', '=', 1);

echo $query->compile();
// output: UPDATE user SET password = ? WHERE user_id = ?

```

Delete
------

[](#delete)

```
$query = new \Peyote\Delete('user');
$query->where('user_id', '=', 1);

echo $query->compile();
// output: DELETE FROM user WHERE user_id = ?

```

Table Statements
----------------

[](#table-statements)

As of version 0.6.0, Peyote now comes bundled with statements to help create, alter and drop tables.

### Create

[](#create)

```
$query = new \Peyote\Create('user');
$query->setColumns(array(
  // Add Columns here....
));

echo $query->compile();
// output: CREATE TABLE user ( {columns here...} ) ENGINE=MyISAM DEFAULT CHARSET=utf8
```

#### Columns

[](#columns)

There are 2 ways to create a column. The first is just to type out the raw SQL as as string. The second is to use a `\Peyote\Column`.

Please see the test folder for more usage examples.

*Note*: Using `serial` as the column type will give set the column as an INT, primary key, not null, unsigned and auto increment.

### Alter

[](#alter)

```
$query = new \Peyote\Alter('user');

// As string...
$query->addColumn('activated TINYINT NOT NULL');

// As Column...
$column = new \Peyote\Column('activated', 'TINYINT', array('is_null' => false));
$query->addColumn($column);

echo $query->compile();
// Output: 'ALTER TABLE user ADD activated TINYINT NOT NULL';
```

### Drop

[](#drop)

```
$query = new \Peyote\Drop('user');
echo $query->compile();
// Output: DROP TABLE user
```

---

Developed by [Dave Widmer](http://www.davewidmer.net)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.3% 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 ~61 days

Total

7

Last Release

4686d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/46fa0decb95ad8d80b65e1fbed54f3fa9ee6350f1c8a0f83335221a201effb59?d=identicon)[davewid](/maintainers/davewid)

---

Top Contributors

[![daveWid](https://avatars.githubusercontent.com/u/116173?v=4)](https://github.com/daveWid "daveWid (113 commits)")[![cbulock](https://avatars.githubusercontent.com/u/176519?v=4)](https://github.com/cbulock "cbulock (1 commits)")[![lordoffreaks](https://avatars.githubusercontent.com/u/953337?v=4)](https://github.com/lordoffreaks "lordoffreaks (1 commits)")

---

Tags

databasemysqlpdocollectionquery builder

### Embed Badge

![Health badge](/badges/bistro-data/health.svg)

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

###  Alternatives

[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)[codesvault/howdy-qb

Mysql Query Builder for WordPress

371.2k1](/packages/codesvault-howdy-qb)

PHPackages © 2026

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