Skip to content

πŸ“Š Database Class β€” A powerful ⚑ and versatile PHP πŸ”€ tool built with mysqli for efficient database management πŸ—ƒοΈ. βœ… CRUD operations β€” Create βž•, Read πŸ“–, Update ✏️, Delete ❌ πŸ” User Authentication β€” Secure login & registration πŸ›‘οΈ πŸ§‚ Password Hashing β€” Using built-in PHP security features πŸ”’

Notifications You must be signed in to change notification settings

Iqbolshoh/php-database-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

54 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Œ PHP Database Manager

πŸš€ This project, developed by Iqbolshoh Ilhomjonov, is a simple and secure PHP database wrapper class that uses MySQLi for database interactions. It provides an easy-to-use interface for executing queries, fetching results, and managing transactions efficiently.

Banner Image

✨ Features

  • πŸ”’ Secure MySQLi connection
  • ⚑ Supports prepared statements
  • πŸ“Š Fetch results as an associative array or object
  • πŸ”„ Transaction management (begin, commit, rollback)
  • ❌ Error handling with exceptions
  • πŸ› οΈ Convenient helper methods for inserting, updating, and deleting data

πŸ“₯ Installation

You can clone the repository from GitHub:

 git clone https://github.com/Iqbolshoh/php-database-manager.git

Or simply include the Database.php file in your project and create an instance of the Database class.

πŸ› οΈ Usage

1️⃣ Initialize the Database

require_once 'Database.php';
$db = new Database();

2️⃣ Running Queries

πŸ” Select Data

$users = $db->query("SELECT * FROM users WHERE email = ?", ['[email protected]']);
print_r($users);

βž• Insert Data

$db->query("INSERT INTO users (name, email) VALUES (?, ?)", ['Iqbolshoh Ilhomjonov', '[email protected]']);

✏️ Update Data

$db->query("UPDATE users SET email = ? WHERE id = ?", ['[email protected]', 3]);

❌ Delete Data

$db->query("DELETE FROM users WHERE id = ?", [3]);

3️⃣ Transactions

$db->beginTransaction();
try {
    $db->query("UPDATE accounts SET balance = balance - ? WHERE id = ?", [100, 1]);
    $db->query("UPDATE accounts SET balance = balance + ? WHERE id = ?", [100, 2]);
    $db->commit();
} catch (Exception $e) {
    $db->rollback();
    echo "Transaction failed: " . $e->getMessage();
}

🚨 Error Handling

If an error occurs, an exception will be thrown. You can catch it like this:

try {
    $db->query("SELECT * FROM nonexistent_table");
} catch (Exception $e) {
    echo "Database error: " . $e->getMessage();
}

πŸ–₯ Technologies Used

PHP MySQL .htaccess Git .env

πŸ“œ License

This project is open-source and available under the MIT License.

🀝 Contributing

🎯 Contributions are welcome! If you have suggestions or want to enhance the project, feel free to fork the repository and submit a pull request.

πŸ“¬ Connect with Me

πŸ’¬ I love meeting new people and discussing tech, business, and creative ideas. Let’s connect! You can reach me on these platforms:

About

πŸ“Š Database Class β€” A powerful ⚑ and versatile PHP πŸ”€ tool built with mysqli for efficient database management πŸ—ƒοΈ. βœ… CRUD operations β€” Create βž•, Read πŸ“–, Update ✏️, Delete ❌ πŸ” User Authentication β€” Secure login & registration πŸ›‘οΈ πŸ§‚ Password Hashing β€” Using built-in PHP security features πŸ”’

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published