{"id":15030133,"url":"https://github.com/brunobmorais/php-database","last_synced_at":"2025-07-15T15:43:33.776Z","repository":{"id":57702993,"uuid":"502380562","full_name":"brunobmorais/php-database","owner":"brunobmorais","description":"PHP package for database handling using PDO","archived":false,"fork":false,"pushed_at":"2025-05-01T12:06:23.000Z","size":127,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-03T02:53:11.717Z","etag":null,"topics":["php","php-","php-pdo","php-pdo-my","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/brunobmorais.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2022-06-11T15:08:50.000Z","updated_at":"2025-05-01T13:46:06.000Z","dependencies_parsed_at":"2024-11-13T23:24:49.693Z","dependency_job_id":"f83f8797-4273-4882-acbb-ec29cce747a5","html_url":"https://github.com/brunobmorais/php-database","commit_stats":{"total_commits":78,"total_committers":2,"mean_commits":39.0,"dds":"0.012820512820512775","last_synced_commit":"37c4a28a0bc9b4721ee1d659ec61c1bb3a24ef48"},"previous_names":[],"tags_count":92,"template":false,"template_full_name":null,"purl":"pkg:github/brunobmorais/php-database","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunobmorais%2Fphp-database","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunobmorais%2Fphp-database/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunobmorais%2Fphp-database/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunobmorais%2Fphp-database/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brunobmorais","download_url":"https://codeload.github.com/brunobmorais/php-database/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunobmorais%2Fphp-database/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265424623,"owners_count":23762881,"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","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":["php","php-","php-pdo","php-pdo-my","php8"],"created_at":"2024-09-24T20:12:32.250Z","updated_at":"2025-07-15T15:43:33.720Z","avatar_url":"https://github.com/brunobmorais.png","language":"PHP","readme":"# Database BMORAIS Code\n\n[![Maintainer](http://img.shields.io/badge/maintainer-@brunobmorais-blue.svg?style=flat-square)](https://linkedin.com/in/brunobmorais)\n[![Source Code](http://img.shields.io/badge/source-bmorais/database-blue.svg?style=flat-square)](https://github.com/brunobmorais/php-database)\n[![PHP from Packagist](https://img.shields.io/packagist/php-v/bmorais/database.svg?style=flat-square)](https://packagist.org/packages/bmorais/database)\n[![Latest Version](https://img.shields.io/github/release/brunobmorais/php-database.svg?style=flat-square)](https://github.com/brunobmorais/php-database/releases)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Quality Score](https://img.shields.io/scrutinizer/g/brunobmorais/php-database.svg?style=flat-square)](https://scrutinizer-ci.com/g/brunobmorais/php-database)\n[![Total Downloads](https://img.shields.io/packagist/dt/bmorais/database.svg?style=flat-square)](https://packagist.org/packages/bmorais/database)\n\n###### The database is a persistent abstraction component of your database that PDO has prepared instructions for performing common routines such as registering, reading, editing, and removing data.\n\nO database é um componente para abstração de persistência no seu banco de dados que usa PDO com prepared statements\npara executar rotinas comuns como cadastrar, ler, editar e remover dados.\n\n## About BMorais Code\n\n###### BMorais Code is a set of small and optimized PHP components for common tasks. Held by Bruno Morais. With them you perform routine tasks with fewer lines, writing less and doing much more.\n\nBMorais Code é um conjunto de pequenos e otimizados componentes PHP para tarefas comuns. Mantido por Bruno Morais. Com eles você executa tarefas rotineiras com poucas linhas, escrevendo menos e fazendo muito mais.\n\n### Highlights\n\n- Easy to set up (Fácil de configurar)\n- Total CRUD asbtration (Asbtração total do CRUD)\n- Create safe models (Crie de modelos seguros)\n- Composer ready (Pronto para o composer)\n- PSR-2 compliant (Compatível com PSR-2)\n\n## Installation\n\nDatabase is available via Composer:\n\n```bash\n\"bmorais/database\": \"1.0.*\"\n```\n\nor run\n\n```bash\ncomposer require bmorais/database\n```\n\n## Documentation\n\n###### For details on how to use the Data Layer, see the sample folder with details in the component directory\n\nPara mais detalhes sobre como usar o Database, veja a pasta de exemplo com detalhes no diretório do componente\n\n#### connection\n\n###### To begin using the Data Layer, you need to connect to the database (MariaDB / MySql). For more connections [PDO connections manual on PHP.net](https://www.php.net/manual/pt_BR/pdo.drivers.php)\n\nPara começar a usar o Data Layer precisamos de uma conexão com o seu banco de dados. Para ver as conexões possíveis\nacesse o [manual de conexões do PDO em PHP.net](https://www.php.net/manual/pt_BR/pdo.drivers.php)\n\n```php\nconst CONFIG_DATA_LAYER = [\n    \"driver\" =\u003e \"mysql\",\n    \"host\" =\u003e \"localhost\",\n    \"port\" =\u003e \"3306\",\n    \"dbname\" =\u003e \"database\",\n    \"username\" =\u003e \"user\",\n    \"passwd\" =\u003e \"\",\n    \"options\" =\u003e [\n        PDO::MYSQL_ATTR_INIT_COMMAND =\u003e \"SET NAMES UTF8, lc_time_names = 'pt_BR'\",\n        PDO::ATTR_ERRMODE =\u003e PDO::ERRMODE_EXCEPTION,\n        PDO::ATTR_DEFAULT_FETCH_MODE =\u003e PDO::FETCH_OBJ,\n        PDO::ATTR_CASE =\u003e PDO::CASE_NATURAL,\n        PDO::MYSQL_ATTR_FOUND_ROWS =\u003e true,\n        PDO::ATTR_STRINGIFY_FETCHES =\u003e true\n    ],\n    \"homologation\" =\u003e \"homologacao\",\n    \"directory_models\" =\u003e \"App\\\\Models\\\\\",\n    \"display_errors_details\" =\u003e true,\n];\n```\n\n#### your model\n\n###### The Database is based on an MVC structure with the Layer Super Type and Active Record design patterns. Soon to consume it is necessary to create the model of your table and inherit the Data Layer.\n\nO database é baseado em uma estrutura MVC com os padrões de projeto Layer Super Type e Active Record. Logo para\nconsumir é necessário criar o modelo de sua tabela e herdar o CRUD.\n\n```php\n\u003c?php\n\nclass Usuario extends Crud\n{\n    public function __construct()\n    {\n        $this-\u003edatabase = \"nomeBD\";\n        $this-\u003etableName = \"USUARIO\";\n        $this-\u003eclassModel = \"AutUserModel\";\n    }\n\n    /**\n    * @param $codusuario\n    * @return array|null\n    */\n    public function buscarIdObj($codusuario)\n    {\n        $result = $this-\u003eselect(\"*\",\"WHERE CODUSUARIO=?\",[$codusuario]);\n        if ($result){\n            return $result;\n        } else {\n            return null;\n        }\n    }\n\n    /**\n    * @param $codusuario\n    * @return AutUserModel[] | null\n     */\n    public function buscarIdModelExample($codusuario)\n    {\n        $result = $this-\u003eselect(\"*\",\"WHERE CODUSUARIO=?\",[$codusuario], true);\n        if ($result){\n            return $result;\n        } else {\n            return null;\n        }\n    }\n\n    /**\n    * @param $codusuario\n    * @return AutUserModel[] | null\n    */\n    public function buscarIdModelExample2($codusuario)\n    {\n        $sql = \"SELECT * FROM AUT_USER AS U WHERE U.CODUSUARIO=?\";\n        $params = array($codusuario);\n        $result = $this-\u003eexecuteSQL($sql,$params);\n        if (!empty($result)){\n            return $this-\u003egetObjModel($result,$this-\u003eclassModel);\n        } else {\n            return null;\n        }\n    }\n    \n    /**\n    * @param $coduser\n    * @return bool\n     */\n    public function updateUser($name, $email, $coduser)\n    {\n        $result = $this-\u003eupdate(\"NAME, EMAIL\", array($name, $email), \"CODUSER=?\");\n        if ($result){\n            return true;\n        } else {\n            return false;\n        }\n    }\n    \n    /**\n    * @param $name\n    * @return bool\n    */\n    public function insertUser($name, $email)\n    {\n        $result = $this-\u003einsert(\"NOME, EMAIL\", array($name, $email));\n        if ($result){\n            return true;\n        } else {\n            return false;\n        }\n    }\n    \n    \n}\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/brunobmorais/database/blob/master/CONTRIBUTING.md) for details.\n\n## Support\n\n###### Security: If you discover any security related issues, please email contato@bmorais.com instead of using the issue tracker.\n\nSe você descobrir algum problema relacionado à segurança, envie um e-mail para contato@bmorais.com em vez de usar o\nrastreador de problemas.\n\nThank you\n\n## Credits\n\n- [Bruno Morais](https://github.com/brunobmorais) (Developer)\n- [Athus Felipe](https://github.com/AthusFelipe) (Developer)\n\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\n🚧 [Contributing Guidelines](https://github.com/angular/angular/blob/main/CONTRIBUTING.md) - Currently being updated 🚧\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the appropriate tag.\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\nRemember to include a tag, and to follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) and [Semantic Versioning](https://semver.org/) when uploading your commit and/or creating the issue.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- ACKNOWLEDGMENTS --\u003e\n## Aknowledgements\n###### Thank you to all the people who contributed to this project, whithout you this project would not be here today.\n\nObrigado a todas as pessoas que contribuíram para este projeto, sem vocês este projeto não estaria aqui hoje.\n\n\u003ca href=\"https://github.com/brunobmorais/php-database/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=brunobmorais/php-database\" /\u003e\n\u003c/a\u003e\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n## License\n\nThe MIT License (MIT). Please see [License File](https://github.com/brunobmorais/database/blob/master/LICENSE) for more\ninformation.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunobmorais%2Fphp-database","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrunobmorais%2Fphp-database","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunobmorais%2Fphp-database/lists"}