DBease is a lightweight and easy-to-use PHP database abstraction library designed for MySQL, using the power of PDO. It simplifies common database operations and offers a flexible query builder, making it a valuable tool for developers who want to interact with databases efficiently.
- Simplified CRUD Operations: Perform Create, Read, Update, and Delete (CRUD) operations with ease.
- Flexible Query Builder: Build complex queries with a fluent interface.
- Custom SQL Execution: Execute raw SQL queries when needed.
- Exception Handling: Robust error handling with detailed exceptions.
- Query Logging: Keep track of executed queries for debugging.
- Table and Column Existence Checks: Verify the existence of tables and columns.
- Composer-Friendly: Easily install and manage using Composer.
DBease can be installed via Composer:
composer require erikthiart/dbease
use DBease\Database;
// Initialize the database connection
$db = new Database();
$data = [
'name' => 'John Doe',
'email' => 'john@example.com',
'age' => 30,
];
// Insert into the 'users' table
$db->insert('users', $data);
$updateData = ['status' => 'active'];
// Update records in the 'users' table where 'id' is 1
$db->update('users', $updateData, ['id' => 1]);
// Find a single record from the 'users' table where 'id' is 1
$user = $db->find('users', ['id' => 1]);
// Find all active users
$activeUsers = $db->findAll('users', ['status' => 'active']);
// Execute a custom SQL query
$sql = "SELECT * FROM products WHERE category = :category";
$params = ['category' => 'Electronics'];
$results = $db->raw($sql, $params);
// Build complex queries
$results = $db
->select('name, price')
->limit(5)
->offset(10)
->fetchWithOffset('products', ['category' => 'Electronics']);
For more examples and detailed documentation, please refer to the DBease Wiki.
Contributions are welcome! Please check the contribution guidelines for details.
DBease is open-source software licensed under the GNU General Public License.
DBease is developed and maintained by Erik Thiart.
If you have questions or need assistance, feel free to open an issue.