DBQ is a lightweight and extendable PHP Query Builder designed to facilitate seamless interaction with MySQL databases. It provides an intuitive interface for:
- Table Management: Effortlessly create and manage database tables.
- CRUD Operations: Perform Create, Read, Update, and Delete operations with minimal code.
- Query Building: Construct complex SQL queries using a fluent and expressive syntax.
This framework can be easily integrated into any PHP project using Composer.
- Database Connection: Simplified methods to connect to MySQL databases.
- Table Creation: Define tables with specified attributes and constraints.
- Data Insertion: Insert records into tables with ease.
- Data Retrieval: Fetch records with support for custom conditions.
- Data Update: Update existing records based on specified conditions.
- Data Deletion: Remove records from tables with specified conditions.
- Query Builder: Build complex SQL queries using a fluent interface.
To use the DBQ Query Builder in your project, follow these steps:
Ensure that Composer is installed on your system. If it's not installed yet, you can install it using the following command:
curl -sS https://getcomposer.org/installer | php{
"require": {
"archerbyte/php-dbq": "dev-develop"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/archerbyte/php-dbq.git"
}
],
"minimum-stability": "dev",
"prefer-stable": true
}Then run:
composer installThis will install the package from the develop branch and download all necessary files.
Ensure that Composer's autoloader is included in your project. Add this line at the beginning of your PHP file:
require 'vendor/autoload.php';You can now use the package in your project. For more information on how to use it, refer to the Usage section of this documentation.
use archerbyte\DBQ;
use archerbyte\DBAttribute;
$dbq = new DBQ();
$dbq->connectMySQL('localhost', 'database_name', 'username', 'password');
// Define table attributes
$attributes = [
new DBAttribute('ID', 'INT', 11, false, true),
new DBAttribute('username', 'VARCHAR', 255, true),
];
// Create table
$dbq->createTable('users', $attributes);
// Insert data
$dbq->insert('users', [
'username' => 'testuser',
]);use archerbyte\QB;
$qb = (new QB())->add('username', 'testuser');
$users = $dbq->selectWithQB('users', $qb);$qb = (new QB())->add('ID', 1);
$dbq->updateWithQB('users', $qb, ['username' => 'updateduser']);$qb = (new QB())->add('ID', 1);
$dbq->deleteWithQB('users', $qb);- connectMySQL: Establishes a connection to the MySQL database.
- createTable: Creates a new table with specified attributes.
- insert: Inserts data into a specified table.
- select: Retrieves data from a specified table.
- selectWithQB: Retrieves data from a specified table with query builder conditions.
- updateWithQB: Updates data in a specified table with query builder conditions.
- deleteWithQB: Deletes data from a specified table with query builder conditions.
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to fork this project, make improvements, and submit pull requests. Contributions are always welcome!