PHPackages                             azaddevx/database - 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. azaddevx/database

ActiveLibrary[Database &amp; ORM](/categories/database)

azaddevx/database
=================

v2.4.0(2y ago)19MITPHPPHP &gt;=8.3.0

Since Mar 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/AzadDevX/Database)[ Packagist](https://packagist.org/packages/azaddevx/database)[ RSS](/packages/azaddevx-database/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)DependenciesVersions (6)Used By (0)

[![AzadSqlBanner](https://private-user-images.githubusercontent.com/158297225/310652864-23f131f0-c061-47e3-bee9-24efae6c0e7e.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyMTgzMDAsIm5iZiI6MTc3NTIxODAwMCwicGF0aCI6Ii8xNTgyOTcyMjUvMzEwNjUyODY0LTIzZjEzMWYwLWMwNjEtNDdlMy1iZWU5LTI0ZWZhZTZjMGU3ZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDAzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwM1QxMjA2NDBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01N2FlNWM1MGMwMWQyMDQ1ZjEyY2YwNzI0NGE1NmJjMDQwMGU5NWQ3NzRmZmQwMDljYTM2YWZiYzdlYmU3N2NkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.bdA-Vx7Rrk-EEmazkZaYTJrFIqigC1EgdbDc3iRzA9M)](https://private-user-images.githubusercontent.com/158297225/310652864-23f131f0-c061-47e3-bee9-24efae6c0e7e.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyMTgzMDAsIm5iZiI6MTc3NTIxODAwMCwicGF0aCI6Ii8xNTgyOTcyMjUvMzEwNjUyODY0LTIzZjEzMWYwLWMwNjEtNDdlMy1iZWU5LTI0ZWZhZTZjMGU3ZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDAzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwM1QxMjA2NDBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01N2FlNWM1MGMwMWQyMDQ1ZjEyY2YwNzI0NGE1NmJjMDQwMGU5NWQ3NzRmZmQwMDljYTM2YWZiYzdlYmU3N2NkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.bdA-Vx7Rrk-EEmazkZaYTJrFIqigC1EgdbDc3iRzA9M)

[![MySQL](https://camo.githubusercontent.com/1b3c1f020909d47c98e2a00b9e5484c252c84684ed3573ffff1e9ee721421887/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d7973716c2d3434373941312e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d6d7973716c266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/1b3c1f020909d47c98e2a00b9e5484c252c84684ed3573ffff1e9ee721421887/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d7973716c2d3434373941312e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d6d7973716c266c6f676f436f6c6f723d7768697465)[![PHP](https://camo.githubusercontent.com/bbeaca4ecdd74d3fde840f711ebb8a5def2ff801187623f9bc365761b3b66f86/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2532333737374242342e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/bbeaca4ecdd74d3fde840f711ebb8a5def2ff801187623f9bc365761b3b66f86/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2532333737374242342e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)

[![GitHub issues](https://camo.githubusercontent.com/9a54220486bd24b378b35f26a954edf47c540c0b4111cf549cb14693b2459f8b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f417a6164446576582f44617461626173652e737667)](https://GitHub.com/AzadDevX/Database/issues/)[![GitHub version](https://camo.githubusercontent.com/ca8354c455399885f6a36e0993397a0b536328063bf01c4e7ab8a7f0f4ce9860/68747470733a2f2f62616467652e667572792e696f2f67682f417a61644465765825324644617461626173652e737667)](https://github.com/AzadDevX/Database)

[![packagist](https://camo.githubusercontent.com/50ffdb5085b9c0f01720bd7159479083926ac40e1cf53c15fd4064c0e49dff3d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f417a6164446576582f4461746162617365)](https://packagist.org/packages/AzadDevX/Database)[![Github all releases](https://camo.githubusercontent.com/4645c13c2354454ccb46059f29042ae4ce0411a33733e6890cf4f397ba09a3cc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f417a6164446576582f44617461626173652f746f74616c2e737667)](https://GitHub.com/AzadDevX/Database/releases/)[![MIT license](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](https://lbesson.mit-license.org/)

1. Introduction
===============

[](#1-introduction)

One of the main goals of the project is to establish a connection with the database in a way that maintains clean code structure while ensuring program speed, despite the use of various automated capabilities and tools. Additionally, employing object-oriented methods in different parts of the project improves team productivity and helps team members gain full mastery in various project areas.

It’s worth noting that this project is still in the testing and debugging phase, and we invite programmers to join us in its development.

2. how does it work
===================

[](#2-how-does-it-work)

This is a developing library for interacting with databases (currently only MySQL). The library can automatically encrypt data, sort it, and also execute Query commands through job definitions without losing information or making unilateral changes.

3. Basic rules
==============

[](#3-basic-rules)

Folder Setup: First, you need to create a folder structure for your project. This folder should include files related to tables, encryption, builders, and other necessary components. Make sure to configure this folder properly. Project Namespace: Alongside configuring the folder, the project name (defined in the configuration class) should serve as a namespace for your project files. This ensures that your project remains organized and that different components can be easily associated with the project.

for example:

```
namespace MyProject\Plugins;
```

Remember that this project is still in the testing and debugging phase, so it’s essential to collaborate with fellow developers to enhance its functionality. If you have any further questions or need assistance, feel free to ask!

4. Initial Setup
================

[](#4-initial-setup)

First, install the azaddevx/database library using Composer. To do this, run the following command in your terminal:

```
composer require azaddevx/database
```

Next, load the library using the autoload.php file:

```
require 'vendor/autoload.php';

// Load the Connect class to start using the library:
$Database = new Azad\Database\Connection(CONFIG CLASS);
```

Now, to begin, you need to create a **configuration class**. The components of the configuration are explained below.

After creating this class, pass it directly to the Connect class.

**Database**: In this section, enter the database connection information. In the future, depending on the type of database you have, the information set for this feature may differ. Currently, this feature includes four elements named as follows:

`host`: Your database host

`username`: The username used for connection

`password`: Your database password

`name`: The name of the database you intend to connect to

**Project**: In this section, your project information including the project name, project folder, etc., is set up

which includes two elements: `directory` and `name`

**Table**: This feature contains the general settings related to the data table. Currently, it includes an element named prefix. The prefix of the data table can essentially serve as a signature for all data tables, placed before the actual name and separated from the main table name by an underscore (\_).

**Log**: This feature is useful when you are debugging your project. The logs save all the operations performed by the library in an insecure file (you must handle the security settings yourself), and you can view the commands executed by the library. It includes the following three elements:

- `file_name`: The name of the file where the logs are saved.
- `save`: The data you need to save in this file, which includes the following elements:

    - **query**: Saves the query commands.
    - **affected\_rows**: Saves the number of changes applied after executing a query.
    - **get\_ram**: Saves the data received from the system’s RAM.
    - **save\_ram**: Saves the data stored in the system’s RAM.
    - **jobs**: Saves the data related to jobs.
    - **database**: Saves all the stored data related to databases.
- `retain_previous_data`: A boolean type, if true, previous logs are retained in the file.

**System**: This feature pertains to the main system of the library, which includes two elements: `RAM` and `Database`.

`RAM`: This feature stores the data received from the database in the system’s RAM, eliminating the need for resending queries to retrieve them again. This process enhances the speed of the project but configuring it is optional.

`Database`: The type of database you intend to connect to; currently, only Mysql is available.

Below is a sample of the configuration class:

```
