{"id":23382123,"url":"https://github.com/hmdnu/sipreman","last_synced_at":"2025-04-10T23:52:27.152Z","repository":{"id":260196147,"uuid":"862786938","full_name":"hmdnu/sipreman","owner":"hmdnu","description":"Student's achievement manager for state polytechnic of malang final projet, built with native php by implementing mvc design pattern and my own sql builder ","archived":false,"fork":false,"pushed_at":"2025-03-22T03:59:26.000Z","size":50031,"stargazers_count":0,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T23:52:21.000Z","etag":null,"topics":["mvc","php","sqlbuilder"],"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/hmdnu.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":"2024-09-25T07:30:24.000Z","updated_at":"2025-03-22T03:59:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"cc356edb-800f-4d29-8db4-e838c347d668","html_url":"https://github.com/hmdnu/sipreman","commit_stats":null,"previous_names":["hmdnu/prestasi-polinema","hmdnu/sipreman"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmdnu%2Fsipreman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmdnu%2Fsipreman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmdnu%2Fsipreman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmdnu%2Fsipreman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hmdnu","download_url":"https://codeload.github.com/hmdnu/sipreman/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317705,"owners_count":21083528,"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":["mvc","php","sqlbuilder"],"created_at":"2024-12-21T21:17:21.186Z","updated_at":"2025-04-10T23:52:27.146Z","avatar_url":"https://github.com/hmdnu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Project Based Learning \n## Sistem Informasi Prestasi Mahasiswa\n\n⚠️⚠️ Note: this docs may be a bit missleading because im too lazy to edit it to new one, and this project is maybe 40% away of being complete and no i wont be finishing it. Feel free to contribute!!\n\nJurusan Teknologi Informasi, Prodi Sistem Informas Bisnis, Politeknik Negeri Malang.\n\n## SQL Builder Guide\n\n## Table of Contents\n1. [DDL](#ddl)\n2. [DML](#dml)\n3. [Safely assign parameters](#safely-assign-parameters)\n4. [Join](#join)\n5. [View](#view)\n6. [Procedure](#procedure)\n7. [Raw query](#raw-query)\n\n### DDL\n```php\n// Work in progress\n```\n\n### DML\n\n```php\nuse app\\cores\\dbal\\Construct;\n\n$construct = new Construct();\n\n// select statement\n$result = $construct\n    -\u003eselect(\"id\", \"name\", \"age\")\n    -\u003efrom(\"user\")-\n    \u003efetch(); // use fetch() to execute query and retrieve columns data\n    \n// SELECT id, name, age FROM [user];\n```\n```php\n// insert statement\n$construct\n    -\u003einsert(\"user\")\n    -\u003evalues([\n        \"id\" =\u003e 123,\n        \"name\" =\u003e \"John Doe\",\n        \"age\" =\u003e 20\n    ])\n    -\u003eexecute() // use execute() to only execute query and return boolean\n\n// INSERT INTO [user] (id, name, age) VALUES (123, 'John Doe', 20);\n```\n```php\n// update statement\n$construct \n    -\u003eupdate(\"user\")\n    -\u003eset(\"name\", \"kevin\")\n    -\u003ewhere(\"name\", \"ujang\")\n    -\u003eexecute();\n    \n// UPDATE [user] SET name = 'kevin' WHERE name = 'ujang';\n```\n\n```php\n// delete statement\n$construct\n    -\u003edelete(\"user\")\n    -\u003ewhere(\"id\", 123)\n    -\u003eexecute();\n\n// DELETE FROM [user] WHERE id = 123;\n```\n---\n\n### Safely Assign Parameters\nyou can safely assign parameters with bindParams() method to prevent sql injection\n\n```php\n$construct\n    -\u003einsert(\"user\")\n    -\u003evalues([\n        \"id\" =\u003e \"?\",\n        \"name\" =\u003e \"?\"\n    ])\n    -\u003ebindParams(1, 123)\n    -\u003ebindParams(2, \"kevin\")\n    -\u003eexecute();\n    \n// INSERT INTO [user] (id, name) VALUES (?, ?);\n\nparams {\n \"id\" =\u003e 123,\n\"name\" =\u003e \"kevin\"\n```\n---\n### Join\n```php\n$result = $construct\n    -\u003eselect(\"id\", \"name\")\n    -\u003efrom(\"user\", \"u\") // you can make alias\n    -\u003einnerJoin(\"student\", \"s\")\n    -\u003eon(\"u.id\", \"s.id\")\n    -\u003efetch();\n    \n // SELECT id, name FROM [user] AS u JOIN [student] AS s ON u.id = s.id;\n\n// multiple join\n$result = $construct\n    -\u003eselect(\"id\", \"name\")\n    -\u003efrom(\"user\", \"u\") // you can make alias\n    -\u003einnerJoin(\"student\", \"s\")\n    -\u003erightJoin(\"admin\", \"a\")\n    -\u003eon(\"u.id\", \"s.id\")\n    -\u003eon(\"u.id\", \"a.id\")\n    -\u003efetch();\n    \n```\n---\n### View\n```php\n// construct the view statement\n$construct\n    -\u003eselect(\"*\")\n    -\u003efrom(\"user\")\n    -\u003eview(\"userView\")\n    -\u003eexecute();\n\n// CREATE VIEW userView AS SELECT * FROM [user];\n\n// query the view\n$view = $construct-\u003eselect(\"*\")-\u003efrom(\"userView\")-\u003efetch();\n// SELECT * FROM [userView];\n```\n---\n### Procedure\n```php\n// construct the procedure\n$construct-\u003eprocedure(\"getUser\", function (Selection $selection) {\n    $selection\n        -\u003esetColumns(\"id\", \"name\")\n        -\u003efrom(\"user\")\n        -\u003ewhere(\"name\", \"@name\");\n})-\u003eaddParam(\"name\", \"nvarchar(10)\")-\u003eexecute();\n\n// exec the procedure\n$res = $construct-\u003ecall(\"getUser\", [\"name\" =\u003e \"ujang\"])-\u003efetch();\n```\n---\n### Raw Query\n\n```php\n$res = $construct-\u003equery(\"SELECT * FROM [user] WHERE role = ?\")\n    -\u003ebindParams(1, \"student\") // always recomend to use bindParams()\n    -\u003efetch();\n```\nit works the same with the sql builder, you use fetch() if you want to return the column results\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmdnu%2Fsipreman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhmdnu%2Fsipreman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmdnu%2Fsipreman/lists"}