PHPackages                             smeghead/phel-pdo - 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. smeghead/phel-pdo

Abandoned → [phel-lang/phel-pdo](/?search=phel-lang%2Fphel-pdo)Library[Database &amp; ORM](/categories/database)

smeghead/phel-pdo
=================

phel-lang pdo wrapper library.

v0.0.8(11mo ago)58[1 issues](https://github.com/phel-lang/phel-pdo/issues)MITDockerfilePHP &gt;=8.2CI passing

Since Apr 23Pushed 9mo ago3 watchersCompare

[ Source](https://github.com/phel-lang/phel-pdo)[ Packagist](https://packagist.org/packages/smeghead/phel-pdo)[ RSS](/packages/smeghead-phel-pdo/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (12)Used By (0)

phel-pdo
========

[](#phel-pdo)

phel-lang pdo wrapper library.

Description
-----------

[](#description)

Inherently, it is very easy to call the functionality of PHP classes from phel code. Therefore, it is not difficult to access the database using PDO directly.

However, if you have to think about PHP classes while writing phel code, there is a concern that a context switch will occur between the phel world and the PHP world, and you will not be able to concentrate on writing the phel code.

Therefore, I created a wrapper library (phel-pdo) that can handle PDO just by calling Phel functions.

Install
-------

[](#install)

Install from composer.

```
composer require phel-lang/phel-pdo
```

Usage
-----

[](#usage)

This is an example of connecting to a file database, creating a table, inserting records, and searching on repl.

```
phel:1> (require phel\pdo)
phel\pdo
phel:2> (require phel\pdo\statement)
phel\pdo\statement
phel:3> (def connection-string "sqlite:database.db")
1
phel:4> (def conn (pdo/connect connection-string))
1
phel:5> (pdo/exec conn "create table t1 (id integer primary key autoincrement, name varchr(10))")
0
phel:6> (pdo/exec conn "insert into t1 (name) values ('phel'), ('php')")
2
phel:7> (def stmt (pdo/query conn "select * from t1 where id = 1"))
1
phel:8> (statement/fetch stmt)
{:id 1 :name phel}
phel:8> (def stmt (pdo/prepare conn "select * from t1 where id = :id"))
1
phel:9> (def stmt (statement/execute stmt {:id 1}))
1
phel:10> (statement/fetch stmt)
{:id 1 :name phel}
```

Reference
---------

[](#reference)

### pdo

[](#pdo)

Represents a connection between PHP and a database server.

#### begin

[](#begin)

Initiates a transaction

```
(begin conn)
```

#### commit

[](#commit)

Commits a transaction

```
(commit conn)
```

#### connect

[](#connect)

Connect database and return connection object. Throws a PDOException if the attempt to connect to the requested database fails

```
(connect dns & [username password options])
```

#### error-code

[](#error-code)

Fetch the SQLSTATE associated with the last operation on the database handle

```
(error-code conn)
```

#### error-info

[](#error-info)

Fetch extended error information associated with the last operation on the database handle

```
(error-info conn)
```

#### exec

[](#exec)

Execute an SQL statement and return the number of affected rows

```
(exec conn stmt & [fetch-mode])
```

#### get-attribute

[](#get-attribute)

Retrieve a database connection attribute

```
(get-attribute conn attribute)
```

#### get-available-drivers

[](#get-available-drivers)

Return an array of available PDO drivers

```
(get-available-drivers conn)
```

#### in-transaction

[](#in-transaction)

Checks if inside a transaction

```
(in-transaction conn)
```

#### last-insert-id

[](#last-insert-id)

Returns the ID of the last inserted row or sequence value

```
(last-insert-id conn)
```

#### prepare

[](#prepare)

Prepares a statement for execution and returns a statement object

```
(prepare conn stmt & [fetch-mode])
```

#### query

[](#query)

Prepares and executes an SQL statement without placeholders

```
(query conn stmt & [fetch-mode])
```

#### quote

[](#quote)

Quotes a string for use in a query

```
(query conn string & [type])
```

#### rollback

[](#rollback)

Rolls back a transaction

```
(rollback conn)
```

#### set-attribute

[](#set-attribute)

Set an attribute

```
(set-attribute conn attribute value)
```

### statement

[](#statement)

Represents a prepared statement and, after the statement is executed, an associated result set.

#### bind-value

[](#bind-value)

Binds a value to a parameter

```
(bind-value statement column value & [type])
```

#### debug-dump-params

[](#debug-dump-params)

Returns an SQL prepared command

```
(debug-dump-params statement)
```

#### execute

[](#execute)

Executes a prepared statement

Note

The return value of the original library, `PDOStatement::execute()`, is a `bool` value representing the result of the `execute` method, while the return value of `statement/execute` returns the statement itself.

```
(execute statement)
```

#### fetch

[](#fetch)

Fetches the next row from a result set

```
(fetch statement)
```

#### fetch-all

[](#fetch-all)

Fetches the remaining rows from a result set

```
(fetch-all statement)
```

#### fetch-column

[](#fetch-column)

Returns a single column from the next row of a result set

```
(fetch-column statement & [column])
```

Development
-----------

[](#development)

### Open shell

[](#open-shell)

```
docker compose build
docker compose run --rm php_cli bash
```

### Test

[](#test)

```
vendor/bin/phel test
```

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance51

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.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 ~51 days

Recently: every ~95 days

Total

9

Last Release

334d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/179acd76bf9ce4197915822481df9901a4f70435e3b2152160b0b227146b9d95?d=identicon)[smeghead](/maintainers/smeghead)

---

Top Contributors

[![smeghead](https://avatars.githubusercontent.com/u/112476?v=4)](https://github.com/smeghead "smeghead (36 commits)")[![Chemaclass](https://avatars.githubusercontent.com/u/5256287?v=4)](https://github.com/Chemaclass "Chemaclass (5 commits)")[![jasalt](https://avatars.githubusercontent.com/u/2306521?v=4)](https://github.com/jasalt "jasalt (1 commits)")

---

Tags

phel-langphel-pdopdophel

### Embed Badge

![Health badge](/badges/smeghead-phel-pdo/health.svg)

```
[![Health](https://phpackages.com/badges/smeghead-phel-pdo/health.svg)](https://phpackages.com/packages/smeghead-phel-pdo)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M69](/packages/ifsnop-mysqldump-php)[nette/database

💾 Nette Database: layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.

5656.7M231](/packages/nette-database)[dibi/dibi

Dibi is Database Abstraction Library for PHP

5013.8M120](/packages/dibi-dibi)[aura/sql

A PDO extension that provides lazy connections, array quoting, query profiling, value binding, and convenience methods for common fetch styles. Because it extends PDO, existing code that uses PDO can use this without any changes to the existing code.

5632.5M43](/packages/aura-sql)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)

PHPackages © 2026

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