https://github.com/oriiyx/bde
Boring Database Engine
https://github.com/oriiyx/bde
cli cli-app database-connector php php-database-connection
Last synced: 18 days ago
JSON representation
Boring Database Engine
- Host: GitHub
- URL: https://github.com/oriiyx/bde
- Owner: oriiyx
- License: mit
- Created: 2025-03-25T18:54:24.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-04T20:08:28.000Z (about 1 year ago)
- Last Synced: 2025-04-04T21:23:51.115Z (about 1 year ago)
- Topics: cli, cli-app, database-connector, php, php-database-connection
- Language: Rust
- Homepage:
- Size: 57.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BDE (Boring Database Engine) - On Hold
## Project Status: Development **Paused**
# Boring Database Engine (BDE)
> A type-safe SQL toolkit for PHP built with Rust
## About
Boring Database Engine (BDE) is a code generator that transforms your SQL queries into type-safe PHP functions. Inspired
by the Go-based SQLC project, BDE brings the same productivity and safety benefits to the PHP ecosystem.
The "boring" philosophy is intentional - database interactions should be predictable, reliable, and free from unexpected
behavior. BDE focuses on generating straightforward, maintainable code without unnecessary complexity.
## Features
- **Type-safe SQL**: Generate PHP functions with proper type signatures from your SQL queries
- **Compile-time validation**: Catch SQL errors before runtime
- **Performance**: Rust-powered parsing and code generation
- **Minimal dependencies**: Clean, straightforward PHP output with no runtime dependencies
- **MySQL support**: First-class support for MySQL (additional databases planned)
## Getting Started
```bash
# Initialize a new project
bde init
# Generate code from your SQL files
bde generate
```
## Example
Define your SQL schema:
```sql
CREATE TABLE users
(
id SERIAL PRIMARY KEY,
username VARCHAR(255) NOT NULL UNIQUE,
email VARCHAR(255) NOT NULL UNIQUE,
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);
```
Write your queries:
```sql
-- name: GetUserByID :one
SELECT *
FROM users
WHERE id = $1;
-- name: ListUsers :many
SELECT *
FROM users
ORDER BY created_at DESC;
-- name: CreateUser :one
INSERT INTO users (username, email)
VALUES ($1, $2) RETURNING *;
```
BDE will generate type-safe PHP code:
```php
pdo = $pdo;
}
public function getUserById(int $id): ?User
{
$stmt = $this->pdo->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$id]);
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
if (!$row) {
return null;
}
$user = new User();
$user->id = (int)$row['id'];
$user->name = $row['name'];
$user->email = $row['email'];
$user->created_at = $row['created_at'];
return $user;
}
public function listUsers(): array
{
// Implementation generated by BDE
}
public function createUser(string $username, string $email): User
{
// Implementation generated by BDE
}
}
```
## Status
BDE is currently in development.
## Contributing
Contributions are currently not welcomed.
## License
MIT
## Author
Peter Paravinja