{"id":21700686,"url":"https://github.com/marcocesarato/php-light-sql-parser","last_synced_at":"2025-10-16T06:44:28.979Z","repository":{"id":62523830,"uuid":"135295763","full_name":"marcocesarato/PHP-Light-SQL-Parser","owner":"marcocesarato","description":" This class can parse SQL to get query type, tables, field values, etc..  It takes an string with a SQL statements and parses it to extract its different components.  Currently the class can extract the SQL query method, the names of the tables involved in the query and the field values that are passed as parameters. This parser is pretty light respect phpsqlparser or others php sql parser.","archived":false,"fork":false,"pushed_at":"2022-12-16T13:21:09.000Z","size":56,"stargazers_count":31,"open_issues_count":5,"forks_count":13,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-14T20:25:45.047Z","etag":null,"topics":["class","database","mysql","parser","php","postrges","sql","sql-parser"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcocesarato.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-05-29T12:53:19.000Z","updated_at":"2025-07-18T23:01:08.000Z","dependencies_parsed_at":"2023-01-29T14:01:01.019Z","dependency_job_id":null,"html_url":"https://github.com/marcocesarato/PHP-Light-SQL-Parser","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/marcocesarato/PHP-Light-SQL-Parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcocesarato%2FPHP-Light-SQL-Parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcocesarato%2FPHP-Light-SQL-Parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcocesarato%2FPHP-Light-SQL-Parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcocesarato%2FPHP-Light-SQL-Parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcocesarato","download_url":"https://codeload.github.com/marcocesarato/PHP-Light-SQL-Parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcocesarato%2FPHP-Light-SQL-Parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279163438,"owners_count":26117456,"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","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"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":["class","database","mysql","parser","php","postrges","sql","sql-parser"],"created_at":"2024-11-25T20:16:01.275Z","updated_at":"2025-10-16T06:44:28.933Z","avatar_url":"https://github.com/marcocesarato.png","language":"PHP","readme":"# PHP Light SQL Parser Class\n\n**Version:** 0.2.105 beta\n\n**Github:** https://github.com/marcocesarato/PHP-Light-SQL-Parser-Class\n\n**Author:** Marco Cesarato\n\n## Description\n\nThis class can parse SQL to get query type, tables, field values, etc..\n\nIt takes an string with a SQL statements and parses it to extract its different components.\n\nCurrently the class can extract the SQL query method, the names of the tables involved in the query and the field values that are passed as parameters.\nThis parser is pretty light respect phpsqlparser or others php sql parser.\n\n## Requirements\n\n- php 4+\n\n## Install\n\n### Composer\n1. Install composer\n2. Type `composer require marcocesarato/sqlparser`\n4. Enjoy\n\n## Usage\n\n```php\n$parser = new LightSQLParser(\"UPDATE Customers AS alias SET ContactName = 'Marco Cesarato', City = 'Milan' WHERE ID = 1;\");\n```\n\nOR\n\n```php\n$parser = new LightSQLParser();\n$parser-\u003esetQuery(\"UPDATE Customers AS alias SET ContactName = 'Marco Cesarato', City = 'Milan' WHERE ID = 1;\");\n```\n\n### Method\nHow to retrieve the query's method:\n```php\n$parser-\u003egetMethod();\n```\nOutput\n```\nstring(6) \"UPDATE\"\n```\n\n### Tables\n\nHow to retrieve the main the query's table:\n```php\n$parser-\u003egetTable();\n```\nOutput\n```\nstring(9) \"Customers\"\n```\n\n\nHow to retrieve the query's tables:\n```php\n$parser-\u003egetAllTables();\n```\nOutput\n```\narray(1) {\n  [0]=\u003e\n  string(9) \"Customers\"\n}\n```\n\n### Fields\nHow to retrieve the query's fields:\n```php\n$parser-\u003egetFields();\n```\nOutput\n```\narray(2) {\n  [0]=\u003e\n  string(11) \"ContactName\"\n  [1]=\u003e\n  string(4) \"City\"\n}\n```\n\n## Methods\n\n\n### LightSQLParser\n\n| Method      | Parameters                          | Description                                        |\n| ----------- | ----------------------------------- | -------------------------------------------------- |\n| __construct |                                     | Constructor                                        |\n| setQuery    |                                     | Set SQL Query string                               |\n| getQuery    |   return array                                  | Get SQL Query string                               |\n| getAllQuery    |  return string                                   | Get SQL All Query string                               |\n| getMethod      | \t  param $query\u003cbr\u003e\t  return string | Get SQL Query method                               |\n| getFields      | \t  param $query\u003cbr\u003e\t  return array  | Get Query fields (at the moment only SELECTINSERTUPDATE) |\n| getTable       | \t  param $query\u003cbr\u003e\t  return string | Get SQL Query First Table                          |\n| getTables      | \t  return array                     | Get SQL Query Tables                               |\n| getJoinTables      | \t  return array                     | Get SQL Query Join Tables                               |\n| hasJoin      | \t  return bool                     | Return if has join tables                               |\n| getSubQueries      | \t  return array                     | Get all SELECT subqueries                              |\n| hasSubQueries      | \t  return bool                     | Return if has subqueries                              |\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcocesarato%2Fphp-light-sql-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcocesarato%2Fphp-light-sql-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcocesarato%2Fphp-light-sql-parser/lists"}