{"id":26611053,"url":"https://github.com/ikto/pgi","last_synced_at":"2026-04-30T18:31:47.341Z","repository":{"id":17487281,"uuid":"20270368","full_name":"ikto/pgi","owner":"ikto","description":"Simple PostgreSQL OOP interface","archived":false,"fork":false,"pushed_at":"2021-06-04T21:07:01.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-05-28T22:42:02.486Z","etag":null,"topics":["dbapi","postgresql"],"latest_commit_sha":null,"homepage":null,"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/ikto.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}},"created_at":"2014-05-28T19:54:20.000Z","updated_at":"2021-06-04T20:59:51.000Z","dependencies_parsed_at":"2022-08-04T19:16:02.254Z","dependency_job_id":null,"html_url":"https://github.com/ikto/pgi","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ikto/pgi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikto%2Fpgi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikto%2Fpgi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikto%2Fpgi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikto%2Fpgi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ikto","download_url":"https://codeload.github.com/ikto/pgi/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikto%2Fpgi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32473804,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"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":["dbapi","postgresql"],"created_at":"2025-03-24T02:25:20.147Z","updated_at":"2026-04-30T18:31:47.325Z","avatar_url":"https://github.com/ikto.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PgI: Simple PostgreSQL OOP interface\n\n[![Build Status](https://travis-ci.org/ikto/pgi.svg?branch=dev)](https://travis-ci.org/ikto/pgi)\n\n## Short description\n\nThis library is inspired by [Perl DBI](http://search.cpan.org/~timb/DBI-1.641/) module.\nIt's database dependent (tied to PostgreSQL), but still tries to be simple.\nAs simple as possible.\n\nIt's may be a good choice if you don't want to use ORM or similar thing for some reason.\nWith this library you don't need to interact with PHP API directly.\nIt provides exceptions for errors, what makes possible to write code more cleanly rather than direct interaction with PHP API.\n\nBut be careful. It won't stop you if you wan't to shoot your leg :).\n\n## Features\n\n - Exceptions for database-level errors.\n - Nested transactions mechanism (using savepoints).\n - Automatic bidirectional data conversion between db and php. For example _timestamp with time zone_ is represented as _DateTime_.\n\n## Requirements (environment)\n\n - PHP 7.0 or higher\n - **pgsql** extension\n \n## How to use\n\nHere is a couple of examples.\n\n```php\nuse IKTO/PgI;\n\n// Connecting to the database.\n$dbh = PgI::connect('host=127.0.0.1 port=5432 dbname=pgi_test', 'postgres', 'postgres');\n\n// Inserting a row into database table.\nif (!$dbh-\u003edoQuery('INSERT INTO \"message\" (name, data) VALUES ($1, $2)', [], ['Welcome!', 'Hello, this is a test!'])) {\n    throw new \\RuntimeException('Something went wrong');\n}\n\n// Updating rows in db.\n$count = $dbh-\u003edoQuery('UPDATE \"record\" SET \"published\" = $1 WHERE \"published\" = $2 AND \"date\" \u003c $3', [], [false, true, DateTime::createFromFormat('Y-m-d', '2013-11-21')]);\necho sprintf(\"We've unpublished %d records\", $count);\n\n// Deleting records from db.\n$count = $dbh-\u003edoQuery('DELETE FROM \"record\" WHERE \"published\" = $1', [], [false]);\necho sprintf(\"We've removed %d unpublished records\", $count);\n\n// Selecting the latest record as associative array.\n$record = $dbh-\u003eselectRowAssoc('SELECT * FROM \"record\" WHERE \"published\" = $1 ORDER BY \"date\" DESC LIMIT 1', [], [true]);\n\n// Selecting the array of available record IDs.\n$ids = $dbh-\u003eselectColArray('SELECT \"id\" FROM \"record\" ORDER BY \"id\" ASC');\n\n// Getting the next sequence value.\n$id = $dbh-\u003egetSeqNextValue('record_id_seq');\n\n// Using transactions.\ntry {\n    $dbh-\u003ebeginWork();\n    \n    $id = $dbh-\u003egetSeqNextValue('record_id_seq');\n    \n    $dbh-\u003edoQuery('INSERT INTO \"record\" (id, date, published) VALUES ($1, NOW(), $2)', [], [$id, false]);\n    \n    $dbh-\u003edoQuery('INSERT INTO \"message\" (id_record, name, data) VALUES ($1, $2, $3)', [], [$id, 'Hello', 'This is a test']);\n    \n    $dbh-\u003edoQuery('UPDATE \"record\" SET \"published\" = $1 WHERE \"id\" = $2', [], [true, $id]);\n    \n    $dbh-\u003ecommit();\n} catch (\\Exception $e) {\n    $dbh-\u003erollback();\n}\n\n```\n\nTo be continued...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikto%2Fpgi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fikto%2Fpgi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikto%2Fpgi/lists"}