{"id":19665466,"url":"https://github.com/dekyfin/easypdo","last_synced_at":"2026-06-08T16:06:13.877Z","repository":{"id":56964994,"uuid":"157566258","full_name":"dekyfin/easypdo","owner":"dekyfin","description":"A convenient wrapper for PDO. Supports only MySQL at the moment","archived":false,"fork":false,"pushed_at":"2018-11-16T18:18:17.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-31T07:57:33.008Z","etag":null,"topics":["pdo-mysql","pdo-wrapper","pdowrapper","php"],"latest_commit_sha":null,"homepage":null,"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/dekyfin.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}},"created_at":"2018-11-14T15:06:01.000Z","updated_at":"2019-01-04T10:22:43.000Z","dependencies_parsed_at":"2022-08-21T10:20:36.432Z","dependency_job_id":null,"html_url":"https://github.com/dekyfin/easypdo","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/dekyfin/easypdo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekyfin%2Feasypdo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekyfin%2Feasypdo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekyfin%2Feasypdo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekyfin%2Feasypdo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dekyfin","download_url":"https://codeload.github.com/dekyfin/easypdo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekyfin%2Feasypdo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34069534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"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":["pdo-mysql","pdo-wrapper","pdowrapper","php"],"created_at":"2024-11-11T16:22:59.669Z","updated_at":"2026-06-08T16:06:13.856Z","avatar_url":"https://github.com/dekyfin.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EasyPDO\nA convenient wrapper for PDO. Supports only MySQL at the moment.\nIt is meant to simplify common queries in order to reduce the code to be written.\n\n## Example\n\n```php\n// Insert row using prepared statement and get insert id\n// PDO\n$stmt = $db-\u003eprepare(\"INSERT INTO table(col1,col2) VALUES(:col1, :col2)\");\n$stmt-\u003eexecute([\"col1\"=\u003e\"val1\", \"col2\"=\u003e\"val2\"]);\n$id = $db-\u003elastInsertId();\n\n// EasyPDO\n$id = $db-\u003einsert(\"table\", [\"col1\" =\u003e \"val1\", \"col2\"=\u003e\"val2\"]);\n\n\n// Select rows from DB\n//PDO\n$stmt2 = $db-\u003eprepare(\"SELECT * FROM table WHERE col1 = :col1 AND col2 = :col2)\");\n$stmt2-\u003eexecute([\"col1\"=\u003e\"val1\", \"col2\"=\u003e\"val2\"]);\n$rows = $db-\u003efetchAll( $stmt2 );\n\n// EasyPDO\n$rows = $db-\u003eselect(\"table\", [\"col1\"=\u003e\"val1\", \"col2\"=\u003e\"val2\"]);\n```\n\n## What Can EasyPDO Do?\n1. Convenient wrappers for all CRUD operations\n\t1. SELECT\n\t2. UPDATE\n\t3. INSERT\n\t4. DELETE\n\t5. INSERT/UPDATE\n2. Easily get the insertId for INSERT, affected rows for UPDATE/DELETE, and array of rows for SELECT statements.\n```php\n/*\tTake note of the  the 2nd parameter:\n*\tA value of true ocauses the function to return the 'convenient data', \n*\twhile false returns the PDOStatement Object\n*/\n\n// Select Statement\n$rows = $db-\u003eexecute(\"SELECT id FROM table WHERE id \u003c :max\", [\"max\"=\u003e3], true);\n// Output: array of matched rows\n\n$insertId = $db-\u003eexecute(\"INSERT INTO table(col1, col2) VALUES(:col1, :col2)\", [\"col1\"=\u003e\"val1\", \"col2\"=\u003e\"val2\"], true);\n//Output: inserId\n\n$affectedRows = $db-\u003eexecute(\"DELETE FROM table WHERE id = :id\", [\"id\"=\u003e5], true);\n//Output: affected rows\n\n$affectedRows = $db-\u003eexecute(\"UPDATE table SET col1 = :col1 WHERE id = :id\", [\"id\"=\u003e5, \"col1\"=\u003e\"valX\"], true);\n//Output: affected rows\n\n```\n3. Use plain old PDO anytime you want\n\n## Installation\n\n### Composer\n```\ncomposer require dekyfin/easypdo\n```\n### Manual\n\n1. Download the zip file\n2. Include `src/DB.php` into your pr\n\n```PHP\nrequire_once \"/path/to/src/DB.php\";\n```\n\n## Usage\n\n```PHP\n\n// Options for connecting to MySQL database\n$options = [\n\t\"host\"=\u003e\"localhost\",\n\t\"user\"=\u003e\"db_user\",\n\t\"db\"=\u003e\"db_name\",\n\t\"pass\"=\u003e\"s3cr3tp@ssw0rd\"\n];\n\n// Create connection\n$db = new DF\\DB($options);\n\n// Run queries\n$rows = $db-\u003equery(\"SELECT * FROM table\", true);\n\n```\n\n# Methods\n\n### select( string $table, array $conditions = [] , mixed $modifiers ): array $rows\nUsed to select rows matching some `$conditions`. This method currently selects all columns. It will be modified in v2.x.x to allow specifying of columns\n\n- `$conditions` An associative array of `$column =\u003e $value` to match against. Uses SQL `AND` operator to match all `$conditions`\n- `$modifiers` int || string\n\t- An integer will limit the number of results. Results in `LIMIT BY $modifiers`\n\t- A string which will be put at the end of the query to modify the behaviour. Example: `ORDER BY id DESC`\n\n```php\n$data = $db-\u003eselect(\"table\", [\"category\"=\u003e3] , 10); //Show only 10 results\n$data = $db-\u003eselect(\"table\", [\"category\"=\u003e3] , \"ORDER BY id DESC\");\n\n```\n### insert( string $table, array $values ): int $insertId\n\n### update( string $table, array $values = [] [, array $conditions] ): int $rowCount\n\n### insertUpdate( string $table, array $values ): int insertId\nNote: This method will return the insertId of the row if insert or update worked successfully\n\n### delete( string $table, array $conditions): int $rowCount\n\n### query( string $sql , boolean $fetchAll = false )\n\nThis function is used to run an sql query.\nReturns array of data if $fetchAll is true, and a PDOStatement object if false\n\n```php\n$data = $db-\u003equery(\"Select id FROM table\", true); // [ [id=\u003e1], [id=\u003e2] ... ]\n\n```\n\n### execute( string $sql, array $values , boolean $fetchAll = false )\nUsed to prepare and execute a statement. Useful for running a one-off prepared statement.\nReturns array of data if $fetchAll is true, and a PDOStatement object if false\n\n```php\n$data = $db-\u003eexecute(\"Select id FROM table WHERE id \u003c :max\", [\"max\"=\u003e3] , true); // [ [id=\u003e1], [id=\u003e2] ... ]\n\n```\n\n### prepare( string $sql ): PDOStatement\n\n```php\n$stmt = $db-\u003eprepare(\"INSERT INTO table(col1,col2) VALUES(:col1, :col1)\");\n\n$stmt-\u003eexecute([\"col1\" =\u003e 3, \"col2\" =\u003e 4 ]);\n$stmt-\u003eexecute([\"col1\" =\u003e 5, \"col2\" =\u003e 6 ]);\n$stmt-\u003eexecute([\"col1\" =\u003e 50, \"col2\" =\u003e 2e6 ]);\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdekyfin%2Feasypdo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdekyfin%2Feasypdo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdekyfin%2Feasypdo/lists"}