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 = ?", ['iilhomjonov777@gmail.com']);
print_r($users);

➕ Insert Data

$db->query("INSERT INTO users (name, email) VALUES (?, ?)", ['Iqbolshoh Ilhomjonov', 'iilhomjonov777@gmail.com']);

✏️ Update Data

$db->query("UPDATE users SET email = ? WHERE id = ?", ['iqbolshoh123@gmail.com', 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