{"id":22577192,"url":"https://github.com/pfrug/dbhelper","last_synced_at":"2026-05-09T10:38:45.879Z","repository":{"id":73032130,"uuid":"499540028","full_name":"pfrug/dbHelper","owner":"pfrug","description":"Laravel helper to print statements generated by the Eloquent ORM","archived":false,"fork":false,"pushed_at":"2022-06-24T17:24:02.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-02T16:16:54.835Z","etag":null,"topics":["eloquent","helpers","laravel","php","sql"],"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/pfrug.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":"2022-06-03T14:22:42.000Z","updated_at":"2023-03-21T17:43:30.000Z","dependencies_parsed_at":"2023-09-18T19:22:40.025Z","dependency_job_id":null,"html_url":"https://github.com/pfrug/dbHelper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfrug%2FdbHelper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfrug%2FdbHelper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfrug%2FdbHelper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfrug%2FdbHelper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pfrug","download_url":"https://codeload.github.com/pfrug/dbHelper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246059336,"owners_count":20717085,"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":["eloquent","helpers","laravel","php","sql"],"created_at":"2024-12-08T04:12:08.702Z","updated_at":"2026-05-09T10:38:45.871Z","avatar_url":"https://github.com/pfrug.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DbHelper\nThe method **sqlFromBindings** combine Builder functions toSql() and getBindings() to obtain as a result the SQL that is going to be executed.\n\n## Usage\n\n``` php\n\t\t\n  $query = Festivity::where('title', 'like', '%test%')\n            -\u003ewhere('user_id', Auth::user()-\u003eid )\n            -\u003ewhere('category_id', 5)\n            -\u003ewhere('country_id', 2)\n            -\u003ewhere('date_from', '\u003e' , \\DB::raw('now()'))\n            -\u003eorderBy('created_at', 'DESC');\n\n  DbHelper::sqlFromBindings($query); \n  /*\n  output:\n  select *\n  from `festivity`\n  where `title` like '%test%' and `user_id` = 1\n      and `category_id` = 5\n      and `country_id` = 2\n      and `date_from` \u003e now()\n  order by `created_at` desc, `created_at` desc\n  */\n\n```\n\n\n:warning: **The query is only for the example. Please don't write queries like this in your controller, Use Scopes**:\n\nThe same query but using scopes:\n\n``` php\n  $query = Festivity::search('test')\n              -\u003ebyAuthUser()\n              -\u003ebyCategory($categoryIid)\n              -\u003ebyCountry($countryId)\n              -\u003efuture();\n              -\u003elatest();\n\n```\n\nOther example\n\n``` php\n  $query = \\DB::table('users')\n            -\u003ejoin('contacts', function ($join) {\n                $join-\u003eon(function($query){\n                    $query-\u003eon('users.id', '=', 'contacts.user_id')\n                    -\u003eorOn(\"contacts.phone\",'users.phone');\n                });\n            })\n            -\u003ejoin('orders', 'users.id', '=', 'orders.user_id')\n            -\u003eselect('users.*', 'contacts.phone', 'orders.price');\n\n  DbHelper::sqlFromBindings($query);\n\n  /*\n  output: (without format)\n  select `users`.*, `contacts`.`phone`, `orders`.`price` \n  from `users` \n      inner join `contacts` on (`users`.`id` = `contacts`.`user_id` or `contacts`.`phone` = `users`.`phone`)\n      inner join `orders` on `users`.`id` = `orders`.`user_id`\n  */\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfrug%2Fdbhelper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpfrug%2Fdbhelper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfrug%2Fdbhelper/lists"}