{"id":13409350,"url":"https://github.com/SergeyTsalkov/meekrodb","last_synced_at":"2025-03-14T14:31:11.163Z","repository":{"id":45207324,"uuid":"1424799","full_name":"SergeyTsalkov/meekrodb","owner":"SergeyTsalkov","description":"MeekroDB -- The Simple PHP MySQL Library","archived":false,"fork":false,"pushed_at":"2024-12-07T07:28:15.000Z","size":568,"stargazers_count":336,"open_issues_count":1,"forks_count":71,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-03-09T08:25:42.092Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://meekro.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SergeyTsalkov.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}},"created_at":"2011-03-01T05:01:27.000Z","updated_at":"2025-03-07T06:44:34.000Z","dependencies_parsed_at":"2023-11-28T07:25:31.587Z","dependency_job_id":"c249ff6a-d5b3-4655-b7a5-c519e5a2db53","html_url":"https://github.com/SergeyTsalkov/meekrodb","commit_stats":{"total_commits":158,"total_committers":5,"mean_commits":31.6,"dds":0.03164556962025311,"last_synced_commit":"86e33fcb8bdba8ef4d01e21b63a930bbeb0af594"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SergeyTsalkov%2Fmeekrodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SergeyTsalkov%2Fmeekrodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SergeyTsalkov%2Fmeekrodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SergeyTsalkov%2Fmeekrodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SergeyTsalkov","download_url":"https://codeload.github.com/SergeyTsalkov/meekrodb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243593348,"owners_count":20316172,"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":[],"created_at":"2024-07-30T20:01:00.090Z","updated_at":"2025-03-14T14:31:10.796Z","avatar_url":"https://github.com/SergeyTsalkov.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"MeekroDB -- The Simple PHP MySQL Library\n========\nLearn more: http://www.meekro.com\n\nMeekroDB is: \n\n* A PHP MySQL library that lets you **get more done with fewer lines of code**, and **makes SQL injection 100% impossible**.\n* Google's #1 search result for \"php mysql library\" since 2013, with **thousands of deployments worldwide**.\n* A library with a **perfect security track record**. No bugs relating to security or SQL injection have ever been discovered.\n* Backwards and forwards-compatible, supporting all PHP versions **from PHP 5.6** all the way through the latest release of **PHP 8**.\n\nInstallation\n========\nWhen you're ready to get started, see the [Quick Start Guide](http://www.meekro.com/quickstart.php) on our website.\n\n### Manual Setup\nInclude the `db.class.php` file into your project and set it up like this:\n\n```php\nrequire_once 'db.class.php';\nDB::$dsn = 'mysql:host=localhost;dbname=meekrodb';\nDB::$user = 'my_database_user';\nDB::$password = 'my_database_password';\n```\n\n### Composer\nAdd this to your `composer.json`\n\n```json\n{\n  \"require\": {\n    \"sergeytsalkov/meekrodb\": \"*\"\n  }\n}\n```\n\nCode Examples\n========\n### Grab some rows from the database and print out a field from each row.\n\n```php\n$accounts = DB::query(\"SELECT * FROM accounts WHERE type = %s AND age \u003e %i\", $type, 15);\nforeach ($accounts as $account) {\n  echo $account['username'] . \"\\n\";\n}\n```\n\n\n\n### Insert a new row.\n\n```php\nDB::insert('mytable', array(\n  'name' =\u003e $name,\n  'rank' =\u003e $rank,\n  'location' =\u003e $location,\n  'age' =\u003e $age,\n  'intelligence' =\u003e $intelligence\n));\n```\n    \n### Grab one row or field\n\n```php\n$account = DB::queryFirstRow(\"SELECT * FROM accounts WHERE username=%s\", 'Joe');\n$number_accounts = DB::queryFirstField(\"SELECT COUNT(*) FROM accounts\");\n```\n\n### Use a list in a query\n```php\nDB::query(\"SELECT * FROM tbl WHERE name IN %ls AND age NOT IN %li\", array('John', 'Bob'), array(12, 15));\n```\n\n### Log all queries and errors\n```php\n// log all queries and errors to file, or ..\nDB::$logfile = '/home/username/logfile.txt';\n\n// log all queries and errors to screen\nDB::$logfile = fopen('php://output', 'w');\n```\n\n### Nested Transactions\n```php\nDB::$nested_transactions = true;\nDB::startTransaction(); // outer transaction\n// .. some queries..\n$depth = DB::startTransaction(); // inner transaction\necho $depth . 'transactions are currently active'; // 2\n \n// .. some queries..\nDB::commit(); // commit inner transaction\n// .. some queries..\nDB::commit(); // commit outer transaction\n```\n    \n### Lots More - See: http://meekro.com/docs\n\n    \nHow is MeekroDB better than PDO?\n========\n### Optional Static Class Mode\nMost web apps will only ever talk to one database. This means that \npassing $db objects to every function of your code just adds unnecessary clutter. \nThe simplest approach is to use static methods such as DB::query(), and that's how \nMeekroDB works. Still, if you need database objects, MeekroDB can do that too.\n\n### Do more with fewer lines of code\nThe code below escapes your parameters for safety, runs the query, and grabs \nthe first row of results. Try doing that in one line with PDO.\n\n```php\n$account = DB::queryFirstRow(\"SELECT * FROM accounts WHERE username=%s\", 'Joe');\n```\n\nOr how about just one field?\n\n```php\n$created_at = DB::queryFirstField(\"SELECT created_at FROM accounts WHERE username=%s\", 'Joe');\n```\n\n### Work with list parameters easily\nUsing MySQL's IN keyword should not be hard. MeekroDB smooths out the syntax for you, \nPDO does not.\n\n```php\n$accounts = DB::query(\"SELECT * FROM accounts WHERE username IN %ls\", array('Joe', 'Frank'));\n```\n\n\n### Simple inserts\nUsing MySQL's INSERT should not be more complicated than passing in an \nassociative array. MeekroDB also simplifies many related commands, including \nthe useful and bizarre INSERT .. ON DUPLICATE UPDATE command. PDO does none of this.\n\n```php\nDB::insert('accounts', array('username' =\u003e 'John', 'password' =\u003e 'whatever'));\n```\n\n### Nested transactions\nMySQL's SAVEPOINT commands lets you create nested transactions, but only \nif you keep track of SAVEPOINT ids yourself. MeekroDB does this for you, \nso you can have nested transactions with no complexity or learning curve.\n\n```php\nDB::$nested_transactions = true;\nDB::startTransaction(); // outer transaction\n// .. some queries..\n$depth = DB::startTransaction(); // inner transaction\necho $depth . 'transactions are currently active'; // 2\n \n// .. some queries..\nDB::commit(); // commit inner transaction\n// .. some queries..\nDB::commit(); // commit outer transaction\n```\n\n### Flexible debug logging and error handling\nYou can log all queries (and any errors they produce) to a file for debugging purposes. You can also add hooks that let you run your own functions at any point in the query handling process.\n\n\nMy Other Projects\n========\nA little shameless self-promotion!\n\n  * [Ark Server Hosting](https://arkservers.io) -- Ark: Survival Evolved server hosting by ArkServers.io!\n  * [brooce](https://github.com/SergeyTsalkov/brooce) - Language-agnostic job queue written in Go! Write your jobs in any language, schedule them from any language, run them anywhere!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSergeyTsalkov%2Fmeekrodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSergeyTsalkov%2Fmeekrodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSergeyTsalkov%2Fmeekrodb/lists"}