{"id":15028635,"url":"https://github.com/hasirciogli/hdb","last_synced_at":"2025-10-14T20:33:55.925Z","repository":{"id":199204244,"uuid":"702352880","full_name":"hasirciogli/HDB","owner":"hasirciogli","description":"Hasirciogli\\Hdb\\Database class, a PHP class designed to simplify database interactions, offering a structure similar to Laravel's database layer.","archived":false,"fork":false,"pushed_at":"2024-06-17T14:55:52.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-19T18:47:15.336Z","etag":null,"topics":["class","database","database-class","database-management","databaselibray","databse","laravel","library","php","php8","php824","php83"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hasirciogli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-09T06:50:25.000Z","updated_at":"2024-06-17T14:56:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"d49e0434-49e8-4af3-a541-6e1bfa530be7","html_url":"https://github.com/hasirciogli/HDB","commit_stats":null,"previous_names":["hasirciogli/hdb"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/hasirciogli/HDB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasirciogli%2FHDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasirciogli%2FHDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasirciogli%2FHDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasirciogli%2FHDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hasirciogli","download_url":"https://codeload.github.com/hasirciogli/HDB/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasirciogli%2FHDB/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020902,"owners_count":26086948,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["class","database","database-class","database-management","databaselibray","databse","laravel","library","php","php8","php824","php83"],"created_at":"2024-09-24T20:08:47.334Z","updated_at":"2025-10-14T20:33:55.908Z","avatar_url":"https://github.com/hasirciogli.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"**README.md for Hasirciogli\\Hdb\\Database Class**\n\n## Introduction\n\nThis README file provides an overview of the `Hasirciogli\\Hdb\\Database` class, a PHP class designed to simplify database interactions, offering a structure similar to Laravel's database layer.\n\n## Features\n\n* **Connection Management:** Establishes a PDO connection to a MySQL database based on configuration provided through an interface (`DatabaseConfigInterface`).\n* **Query Building:** Facilitates the construction of SQL queries using a chainable method approach.\n* **Prepared Statements:** Employs prepared statements to prevent SQL injection vulnerabilities.\n* **Data Binding:** Allows for binding of parameters to queries for dynamic data handling.\n* **Execution and Retrieval:** Executes the built query and retrieves results as associative arrays or a single row.\n\n## Installation\n\n**1. Composer (Recommended):**\n\nIf you're using Composer in your project, add the package to your `composer.json` file:\n\n```json\n\"require\": {\n    \"hasirciogli/hdb\": \"^1.0\" // Replace with the specific version you want\n}\n```\n\nThen, run `composer install` to download the package.\n\n**2. Manual Download:**\n\nDownload the `Hasirciogli\\Hdb` directory and include it in your project's file structure.\n\n## Usage\n\n**1. Configuration:**\n\nCreate a class that implements the `DatabaseConfigInterface`. This interface defines properties for database credentials and connection details:\n\n```php\ninterface DatabaseConfigInterface\n{\n    const DB_HOST = 'localhost';\n    const DB_NAME = 'your_database_name';\n    const DB_USER = 'your_username';\n    const DB_PASS = 'your_password';\n}\n```\n\n**2. Database Connection:**\n\nInstantiate the `Database` class, passing an instance of your configuration class:\n\n```php\nuse Hasirciogli\\Hdb\\Database;\nuse MyProject\\DatabaseConfig; // Replace with your config class path\n\n$db = Database::cfun(new DatabaseConfig());\n```\n\n**3. Building Queries:**\n\nUse chainable methods to construct your SQL queries:\n\n```php\n$users = $db-\u003eSelect('users')\n            -\u003eWhere('isActive', true)\n            -\u003eOrderBy('username', 'ASC')\n            -\u003eGet('all'); // Get all results as an array\n```\n\n**4. Prepared Statements and Data Binding:**\n\nThe class utilizes prepared statements and data binding automatically. You don't need to manually escape values:\n\n```php\n$userId = 123;\n$user = $db-\u003eSelect('users')\n            -\u003eWhere('id', $userId)\n            -\u003eGet(); // Get a single user row\n```\n\n**5. Additional Methods:**\n\n* `Use(string $DbName)`: Selects a specific database within the connection.\n* `LastInsertId()`: Retrieves the last inserted ID after an `INSERT` operation.\n* `Insert(string $TableName, $Dataset)`: Builds an `INSERT` query with the specified table name and data.\n* `CustomSql(string $Sql)`: Allows for execution of raw SQL queries.\n\n## Error Handling\n\nThe `CheckDB()` method throws an exception if a database connection cannot be established. Handle this exception in your code to provide appropriate error messages.\n\n## Security Considerations\n\nWhile the `Database` class utilizes prepared statements, it's still recommended to validate user input before using it in queries to prevent potential security issues.\n\n## Contribution\n\nWe welcome contributions to improve this library! Fork the repository on GitHub and submit pull requests with your enhancements.\n\n## License\n\nThis library is licensed under the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhasirciogli%2Fhdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhasirciogli%2Fhdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhasirciogli%2Fhdb/lists"}