{"id":22716727,"url":"https://github.com/carry0987/sanite","last_synced_at":"2026-02-01T03:02:20.852Z","repository":{"id":209981161,"uuid":"723999099","full_name":"carry0987/Sanite","owner":"carry0987","description":"Sanite is a PHP library that provide base CRUD structure and methods, using PDO","archived":false,"fork":false,"pushed_at":"2025-12-22T12:10:49.000Z","size":74,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-23T17:58:01.081Z","etag":null,"topics":["crud","database","pdo","php8"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carry0987.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-11-27T07:31:08.000Z","updated_at":"2025-12-22T12:10:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"d38ada67-6fdd-486a-a637-f9d2c6761632","html_url":"https://github.com/carry0987/Sanite","commit_stats":null,"previous_names":["carry0987/sanite"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/carry0987/Sanite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carry0987%2FSanite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carry0987%2FSanite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carry0987%2FSanite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carry0987%2FSanite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carry0987","download_url":"https://codeload.github.com/carry0987/Sanite/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carry0987%2FSanite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28965436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T02:14:24.993Z","status":"ssl_error","status_checked_at":"2026-02-01T02:13:55.706Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["crud","database","pdo","php8"],"created_at":"2024-12-10T14:10:52.752Z","updated_at":"2026-02-01T03:02:20.830Z","avatar_url":"https://github.com/carry0987.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sanite\n[![Packgist](https://img.shields.io/packagist/v/carry0987/sanite.svg?style=flat-square)](https://packagist.org/packages/carry0987/sanite) \n![CI](https://github.com/carry0987/Sanite/actions/workflows/php-unit.yml/badge.svg)  \nSanite is a PHP library that provide base CRUD structure and methods, using PDO.\n\n## Getting Started\nMake sure you have `Sanite` installed. If not, you can install it with the following command:\n\n```bash\ncomposer require carry0987/sanite\n```\n\nAfter installation, you can include `Sanite` in your project and start using it.\n\n## Establishing a Database Connection\n\nUse `Sanite` to establish a database connection:\n\n```php\nuse carry0987\\Sanite\\Sanite;\n\n// Database connection settings\n$config = array(\n    'host' =\u003e 'mariadb',\n    'database' =\u003e 'dev_sanite',\n    'username' =\u003e 'test_user',\n    'password' =\u003e 'test1234',\n    'port' =\u003e 3306, // Optional\n    'charset' =\u003e 'utf8mb4' // Optional\n);\n\n// Create a database connection\n$sanite = new Sanite($config);\n```\n\n## Using a Data Model\n\nCreate your own data models to perform CRUD operations. Here's an example of using `UserModel` to retrieve user data.\n\nFirst, ensure your model extends `DataReadModel` (or corresponding `DataCreateModel`, `DataDeleteModel`, `DataUpdateModel`):\n\n```php\nnamespace carry0987\\Sanite\\Example;\n\nuse carry0987\\Sanite\\Models\\DataReadModel;\n\nclass UserModel extends DataReadModel\n{\n    // Implement your methods, for example:\n    public function getUserById(int $userId)\n    {\n        $queryArray = [\n            'query' =\u003e 'SELECT * FROM user WHERE uid = ? LIMIT 1',\n            'bind'  =\u003e 'i',  // This value needs to be relative when using DBUtil::getPDOType\n        ];\n        $dataArray = [$userId];\n\n        return $this-\u003egetSingleData($queryArray, $dataArray);\n    }\n\n    public function getAllUsers()\n    {\n        $queryArray = [\n            'query' =\u003e 'SELECT * FROM user'\n        ];\n\n        return $this-\u003egetMultipleData($queryArray);\n    }\n}\n```\n\nThen, you can use your model like so:\n\n```php\nuse carry0987\\Sanite\\Example\\UserModel;\n\n// Instantiate UserModel\n$userModel = new UserModel($sanite);\n\n// Retrieve user information for user with ID 1\n$user = $userModel-\u003egetUserById(1);\n$users = $userModel-\u003egetAllUsers();\n\nprint_r($user);\nprint_r($users);\n```\n\n## Exception Handling\n\n`Sanite` defines a specific exception class `DatabaseException`. Capture and handle it appropriately in your code:\n\n```php\ntry {\n    // ... attempt some database operations ...\n} catch (\\carry0987\\Sanite\\Exceptions\\DatabaseException $e) {\n    // ... handle database exception ...\n    echo \"Error: \" . $e-\u003egetMessage();\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarry0987%2Fsanite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarry0987%2Fsanite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarry0987%2Fsanite/lists"}