{"id":26849025,"url":"https://github.com/crodas/sqlparser","last_synced_at":"2025-05-02T20:04:55.681Z","repository":{"id":52989387,"uuid":"41507821","full_name":"crodas/SQLParser","owner":"crodas","description":"SQL-Parser","archived":false,"fork":false,"pushed_at":"2021-04-10T20:20:57.000Z","size":712,"stargazers_count":13,"open_issues_count":2,"forks_count":3,"subscribers_count":7,"default_branch":"develop","last_synced_at":"2025-05-01T15:09:12.708Z","etag":null,"topics":["mysql","parser","sql","sql-parser"],"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/crodas.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":"2015-08-27T19:44:34.000Z","updated_at":"2022-08-21T16:35:31.000Z","dependencies_parsed_at":"2022-08-21T09:50:58.426Z","dependency_job_id":null,"html_url":"https://github.com/crodas/SQLParser","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crodas%2FSQLParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crodas%2FSQLParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crodas%2FSQLParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crodas%2FSQLParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crodas","download_url":"https://codeload.github.com/crodas/SQLParser/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251895479,"owners_count":21661345,"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":["mysql","parser","sql","sql-parser"],"created_at":"2025-03-30T21:24:11.538Z","updated_at":"2025-05-01T15:09:17.017Z","avatar_url":"https://github.com/crodas.png","language":"PHP","readme":"# SQLParser\n\nSQL-Parser\n\nWhy?\n---\n\nSometimes we need to parse and validate SQL.\n\nWhat does it do?\n---------------\n\nIt parses SQL (mostly MySQL's SQL) and returns the SQL query as an object. This object can be modified programmatically to generate another SQL query.\n\nHow to install?\n--------------\n\n```\ncomposer install crodas/sql-parser\n```\n\nHow to use it?\n-------------\n\n```php\nrequire __DIR__ . \"/vendor/autoload.php\";\n\n$parser = new SQLParser;\n$queries = $parser-\u003eparse(\"SELECT * FROM table1 WHERE id = :id\");\nvar_dump(get_class($queries[0])); // string(16) \"SQLParser\\Select\"\nvar_dump($queries[0]-\u003egetTable()[0]-\u003egetValue()); // string(6) \"table1\"\n/*\n array(1) {\n   [0] =\u003e\n   string(2) \"id\"\n   }\n*/\nvar_dump($queries[0]-\u003egetVariables()); \n\n// SELECT * FROM 'table1' WHERE 'id' = :id\necho $queries[0] . \"\\n\";\n\nSQLParser\\Writer\\SQL::setInstance(new SQLParser\\Writer\\MySQL);\n\n// SELECT * FROM `table1` WHERE `id` = :id\necho $queries[0] . \"\\n\";\n```\n\nTODO:\n----\n\n1. Better documentation\n2. Fluent-Interface to generate SQL statements and alter the parsed content\n3. parse CREATE TABLE/ALTER TABLE (for SQLite, MySQL and PostgreSQL flavors)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrodas%2Fsqlparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrodas%2Fsqlparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrodas%2Fsqlparser/lists"}