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

ActiveLibrary

eden/sql
========

SQL core methods for MySQL, Posgres and SQLite

4.0.1(10y ago)114.2k7[1 issues](https://github.com/Eden-PHP/Sql/issues)[2 PRs](https://github.com/Eden-PHP/Sql/pulls)3MITPHPPHP &gt;=5.4.1

Since Sep 17Pushed 8y ago12 watchersCompare

[ Source](https://github.com/Eden-PHP/Sql)[ Packagist](https://packagist.org/packages/eden/sql)[ Docs](http://eden-php.com)[ RSS](/packages/eden-sql/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (6)Dependencies (5)Versions (9)Used By (3)

[![logo](https://camo.githubusercontent.com/683ba05b2b51f50045c674b19a4f0ceb30702a8ab495623be7c02e07ab226f08/687474703a2f2f6564656e2e6f70656e6f766174652e636f6d2f6173736574732f696d616765732f636c6f75642d736f6369616c2e706e67)](https://camo.githubusercontent.com/683ba05b2b51f50045c674b19a4f0ceb30702a8ab495623be7c02e07ab226f08/687474703a2f2f6564656e2e6f70656e6f766174652e636f6d2f6173736574732f696d616765732f636c6f75642d736f6369616c2e706e67) Eden Sql
==============================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#-eden-sql)

[![Build Status](https://camo.githubusercontent.com/eb96977ad1997ab98286f0d8d68cbaad0c276fc6c1ac1d71073496e22700c60b/68747470733a2f2f6170692e7472617669732d63692e6f72672f4564656e2d5048502f53716c2e737667)](https://travis-ci.org/Eden-PHP/Sql)
===============================================================================================================================================================================================================================================

[](#)

- [Install](#install)
- [Introduction](#intro)
- [API](#api)
    - [bind](#bind)
    - [collection](#collection)
    - [delete](#delete)
    - [deleteRows](#deleteRows)
    - [getBinds](#getBinds)
    - [getConnection](#getConnection)
    - [getLastInsertedId](#getLastInsertedId)
    - [getModel](#getModel)
    - [getQueries](#getQueries)
    - [getRow](#getRow)
    - [insert](#insert)
    - [insertRow](#insertRow)
    - [insertRows](#insertRows)
    - [model](#model)
    - [query](#query)
    - [search](#search)
    - [select](#select)
    - [setBinds](#setBinds)
    - [setCollection](#setCollection)
    - [setModel](#setModel)
    - [setRow](#setRow)
    - [update](#update)
    - [updateRows](#updateRows)
- [Contributing](#contributing)

====

Install
-------

[](#install)

`composer install eden/sql`

====

Introduction
------------

[](#introduction)

SQL is an abstract package used in:

- [MySQL](https://github.com/Eden-PHP/Mysql)
- [PostGre](https://github.com/Eden-PHP/Postgre)
- [SQLite](Sqlite)

See these documentations for more details. The following API methods are common amongst all SQL type databases.

====

API
---

[](#api)

====

### bind

[](#bind)

Binds a value and returns the bound key

#### Usage

[](#usage)

```
eden('sql')->bind(*string|array|number|null $value);

```

#### Parameters

[](#parameters)

- `*string|array|number|null $value` - What to bind

Returns `string`

#### Example

[](#example)

```
eden('sql')->bind('foo');

```

====

### collection

[](#collection)

Returns collection

#### Usage

[](#usage-1)

```
eden('sql')->collection(array $data);

```

#### Parameters

[](#parameters-1)

- `array $data` - Initial collection data

Returns `Eden\Sql\Collection`

#### Example

[](#example-1)

```
eden('sql')->collection();

```

====

### delete

[](#delete)

Returns the delete query builder

#### Usage

[](#usage-2)

```
eden('sql')->delete(*string|null $table);

```

#### Parameters

[](#parameters-2)

- `*string|null $table` - The table name

Returns `Eden\Sql\Delete`

#### Example

[](#example-2)

```
eden('sql')->delete('foo');

```

====

### deleteRows

[](#deleterows)

Removes rows that match a filter

#### Usage

[](#usage-3)

```
eden('sql')->deleteRows(*string|null $table, array|string $filters);

```

#### Parameters

[](#parameters-3)

- `*string|null $table` - The table name
- `array|string $filters` - Filters to test against

Returns `Eden\Sql\Collection`

#### Example

[](#example-3)

```
eden('sql')->deleteRows('foo');

```

====

### getBinds

[](#getbinds)

Returns all the bound values of this query

#### Usage

[](#usage-4)

```
eden('sql')->getBinds();

```

#### Parameters

[](#parameters-4)

Returns `array`

====

### getConnection

[](#getconnection)

Returns the connection object if no connection has been made it will attempt to make it

#### Usage

[](#usage-5)

```
eden('sql')->getConnection();

```

#### Parameters

[](#parameters-5)

Returns `resource` - PDO connection resource

====

### getLastInsertedId

[](#getlastinsertedid)

Returns the last inserted id

#### Usage

[](#usage-6)

```
eden('sql')->getLastInsertedId(string|null $column);

```

#### Parameters

[](#parameters-6)

- `string|null $column` - A particular column name

Returns `int` - the id

#### Example

[](#example-4)

```
eden('sql')->getLastInsertedId();

```

====

### getModel

[](#getmodel)

Returns a model given the column name and the value

#### Usage

[](#usage-7)

```
eden('sql')->getModel(*string $table, *string $name, *scalar|null $value);

```

#### Parameters

[](#parameters-7)

- `*string $table` - Table name
- `*string $name` - Column name
- `*scalar|null $value` - Column value

Returns `Eden\Sql\Model|null`

#### Example

[](#example-5)

```
eden('sql')->getModel('foo', 'foo', $value);

```

====

### getQueries

[](#getqueries)

Returns the history of queries made still in memory

#### Usage

[](#usage-8)

```
eden('sql')->getQueries(int|string|null $index);

```

#### Parameters

[](#parameters-8)

- `int|string|null $index` - A particular index to return

Returns `array|null` - the queries

#### Example

[](#example-6)

```
eden('sql')->getQueries();

```

====

### getRow

[](#getrow)

Returns a 1 row result given the column name and the value

#### Usage

[](#usage-9)

```
eden('sql')->getRow(*string $table, *string $name, *scalar|null $value);

```

#### Parameters

[](#parameters-9)

- `*string $table` - Table name
- `*string $name` - Column name
- `*scalar|null $value` - Column value

Returns `array|null`

#### Example

[](#example-7)

```
eden('sql')->getRow('foo', 'foo', $value);

```

====

### insert

[](#insert)

Returns the insert query builder

#### Usage

[](#usage-10)

```
eden('sql')->insert(string|null $table);

```

#### Parameters

[](#parameters-10)

- `string|null $table` - Name of table

Returns `Eden\Sql\Insert`

#### Example

[](#example-8)

```
eden('sql')->insert();

```

====

### insertRow

[](#insertrow)

Inserts data into a table and returns the ID

#### Usage

[](#usage-11)

```
eden('sql')->insertRow(*string $table, *array $setting, bool|array $bind);

```

#### Parameters

[](#parameters-11)

- `*string $table` - Table name
- `*array $setting` - Key/value array matching table columns
- `bool|array $bind` - Whether to compute with binded variables

Returns `Eden\Sql\Index`

#### Example

[](#example-9)

```
eden('sql')->insertRow('foo', array('foo' => 'bar'));

```

====

### insertRows

[](#insertrows)

Inserts multiple rows into a table

#### Usage

[](#usage-12)

```
eden('sql')->insertRows(*string $table, array $setting, bool|array $bind);

```

#### Parameters

[](#parameters-12)

- `*string $table` - Table name
- `array $setting` - Key/value 2D array matching table columns
- `bool|array $bind` - Whether to compute with binded variables

Returns `Eden\Sql\Index`

#### Example

[](#example-10)

```
eden('sql')->insertRows('foo');

```

====

### model

[](#model)

Returns model

#### Usage

[](#usage-13)

```
eden('sql')->model(array $data);

```

#### Parameters

[](#parameters-13)

- `array $data` - The initial data to set

Returns `Eden\Sql\Model`

#### Example

[](#example-11)

```
eden('sql')->model();

```

====

### query

[](#query)

Queries the database

#### Usage

[](#usage-14)

```
eden('sql')->query(*string $query, array $binds);

```

#### Parameters

[](#parameters-14)

- `*string $query` - The query to ran
- `array $binds` - List of binded values

Returns `array`

#### Example

[](#example-12)

```
eden('sql')->query('foo');

```

====

### search

[](#search)

Returns search

#### Usage

[](#usage-15)

```
eden('sql')->search(string|null $table);

```

#### Parameters

[](#parameters-15)

- `string|null $table` - Table name

Returns `Eden\Sql\Search`

#### Example

[](#example-13)

```
eden('sql')->search();

```

====

### select

[](#select)

Returns the select query builder

#### Usage

[](#usage-16)

```
eden('sql')->select(string|array $select);

```

#### Parameters

[](#parameters-16)

- `string|array $select` - Column list

Returns `Eden\Sql\Select`

#### Example

[](#example-14)

```
eden('sql')->select();

```

====

### setBinds

[](#setbinds)

Sets all the bound values of this query

#### Usage

[](#usage-17)

```
eden('sql')->setBinds(*array $binds);

```

#### Parameters

[](#parameters-17)

- `*array $binds` - key/values to bind

Returns `Eden\Sql\Index`

#### Example

[](#example-15)

```
eden('sql')->setBinds(array('foo' => 'bar'));

```

====

### setCollection

[](#setcollection)

Sets default collection

#### Usage

[](#usage-18)

```
eden('sql')->setCollection(*string $collection);

```

#### Parameters

[](#parameters-18)

- `*string $collection` - Collection class name

Returns `Eden\Sql\Index`

#### Example

[](#example-16)

```
eden('sql')->setCollection('foo');

```

====

### setModel

[](#setmodel)

Sets the default model

#### Usage

[](#usage-19)

```
eden('sql')->setModel(*string Model);

```

#### Parameters

[](#parameters-19)

- `*string Model` - class name

Returns `Eden\Sql\Index`

#### Example

[](#example-17)

```
eden('sql')->setModel('foo');

```

====

### setRow

[](#setrow)

Sets only 1 row given the column name and the value

#### Usage

[](#usage-20)

```
eden('sql')->setRow(*string $table, *string $name, *scalar|null $value, *array $setting);

```

#### Parameters

[](#parameters-20)

- `*string $table` - Table name
- `*string $name` - Column name
- `*scalar|null $value` - Column value
- `*array $setting` - Key/value array matching table columns

Returns `Eden\Sql\Index`

#### Example

[](#example-18)

```
eden('sql')->setRow('foo', 'foo', $value, array('foo' => 'bar'));

```

====

### update

[](#update)

Returns the update query builder

#### Usage

[](#usage-21)

```
eden('sql')->update(string|null $table);

```

#### Parameters

[](#parameters-21)

- `string|null $table` - Name of table

Returns `Eden\Sql\Update`

#### Example

[](#example-19)

```
eden('sql')->update();

```

====

### updateRows

[](#updaterows)

Updates rows that match a filter given the update settings

#### Usage

[](#usage-22)

```
eden('sql')->updateRows(*string $table, *array $setting, array|string $filters, bool|array $bind);

```

#### Parameters

[](#parameters-22)

- `*string $table` - Table name
- `*array $setting` - Key/value array matching table columns
- `array|string $filters` - Filters to test against
- `bool|array $bind` - Whether to compute with binded variables

Returns `Eden\Sql\Index`

#### Example

[](#example-20)

```
eden('sql')->updateRows('foo', array('foo' => 'bar'));

```

====

\#Contributing to Eden

Contributions to *Eden* are following the Github work flow. Please read up before contributing.

\##Setting up your machine with the Eden repository and your fork

1. Fork the repository
2. Fire up your local terminal create a new branch from the `v4` branch of your fork with a branch name describing what your changes are. Possible branch name types:
    - bugfix
    - feature
    - improvement
3. Make your changes. Always make sure to sign-off (-s) on all commits made (git commit -s -m "Commit message")

\##Making pull requests

1. Please ensure to run `phpunit` before making a pull request.
2. Push your code to your remote forked version.
3. Go back to your forked version on GitHub and submit a pull request.
4. An Eden developer will review your code and merge it in when it has been classified as suitable.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~136 days

Recently: every ~51 days

Total

8

Last Release

3668d ago

Major Versions

1.0.3 → 4.0.12015-10-13

PHP version history (2 changes)1.0.0PHP &gt;=5.3.1

4.0.1PHP &gt;=5.4.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/120378?v=4)[Christian Blanquera](/maintainers/cblanquera)[@cblanquera](https://github.com/cblanquera)

---

Top Contributors

[![clark21](https://avatars.githubusercontent.com/u/5639521?v=4)](https://github.com/clark21 "clark21 (6 commits)")[![kzap](https://avatars.githubusercontent.com/u/62213?v=4)](https://github.com/kzap "kzap (2 commits)")[![riamaria](https://avatars.githubusercontent.com/u/899900?v=4)](https://github.com/riamaria "riamaria (2 commits)")[![soycaringal](https://avatars.githubusercontent.com/u/8705300?v=4)](https://github.com/soycaringal "soycaringal (2 commits)")

---

Tags

libraryeden

### Embed Badge

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

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

###  Alternatives

[eden/mail

Eden POP3, IMAP and SMTP component

178273.4k1](/packages/eden-mail)[eden/sqlite

Eden SQLite Search, Collection, Model ORM componen

199.2k2](/packages/eden-sqlite)

PHPackages © 2026

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