{"id":18550300,"url":"https://github.com/xp-forge/sql-parser","last_synced_at":"2025-05-15T10:08:58.946Z","repository":{"id":57084824,"uuid":"310680930","full_name":"xp-forge/sql-parser","owner":"xp-forge","description":"SQL Parser","archived":false,"fork":false,"pushed_at":"2024-03-24T13:26:20.000Z","size":67,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-12T23:02:12.628Z","etag":null,"topics":[],"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/xp-forge.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","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":"2020-11-06T18:52:59.000Z","updated_at":"2022-02-27T10:47:21.000Z","dependencies_parsed_at":"2022-08-24T14:59:11.328Z","dependency_job_id":null,"html_url":"https://github.com/xp-forge/sql-parser","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fsql-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fsql-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fsql-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fsql-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xp-forge","download_url":"https://codeload.github.com/xp-forge/sql-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319722,"owners_count":22051075,"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-11-06T21:04:09.936Z","updated_at":"2025-05-15T10:08:58.921Z","avatar_url":"https://github.com/xp-forge.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"SQL Parser\n==========\n\n[![Build status on GitHub](https://github.com/xp-forge/sql-parser/workflows/Tests/badge.svg)](https://github.com/xp-forge/sql-parser/actions)\n[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)\n[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)\n[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)\n[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)\n[![Latest Stable Version](https://poser.pugx.org/xp-forge/sql-parser/version.png)](https://packagist.org/packages/xp-forge/sql-parser)\n\nThis library parses SQL statements.\n\nExamples\n--------\n\n```php\nuse text\\sql\\{Parser, SyntaxError};\n\n$p= new Parser();\ntry {\n  $statement= $p-\u003eparse('select * from user where user_id = 1');\n} catch (SyntaxError $e) {\n  // Handle\n}\n\n// new Select(\n//   [new All()],\n//   [new Table('user')],\n//   new Comparison(new Field(null, 'uid'), '=', new Number(1))\n// )\n```\n\nSupport\n-------\nThis library is not yet complete. Currently, the following are supported:\n\n* USE database selection\n* SELECT, INSERT, UPDATE and DELETE statements\n* CREATE / DROP TABLE schema modification\n* ALTER TABLE ADD / DROP COLUMN table modification\n\nOther statements may be added via `extend()`:\n\n```php\nuse text\\sql\\Parser;\n\n$p= new Parser();\n\n// Incomplete implementation of https://dev.mysql.com/doc/refman/8.0/en/show.html\n$p-\u003eextend('show', function($parse, $token) {\n  return ['show' =\u003e $parse-\u003ematch([\n    'events'    =\u003e function($parse, $token) { return 'events'; },\n    'variables' =\u003e function($parse, $token) {\n      if ('like' === $parse-\u003etoken-\u003esymbol-\u003eid) {\n        $parse-\u003eforward();\n        return ['variables' =\u003e $parse-\u003eexpression()];\n      } else {\n        return ['variables' =\u003e null];\n      }\n    }\n  ])];\n});\n\n$statement= $p-\u003eparse('show variables like \"sql_mode\"');\n\n// ['show' =\u003e ['variables' =\u003e new Text('sql_mode')]]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Fsql-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxp-forge%2Fsql-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Fsql-parser/lists"}