Recommend this page to a friend! |
Download .zip |
Info | Example | View files (7) | Download .zip | Reputation | Support forum (2) | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2020-09-29 (5 months ago) | Not enough user ratings | Total: 208 This week: 2 | All time: 8,249 This week: 182 |
Version | License | PHP version | Categories | |||
lightsqlparser 0.1.96 | Free for non-comm... | 5 | PHP 5, Databases, Parsers |
Collaborate with this project | Author | |
PHP-Light-SQL-Parser - github.com Description This class can parse SQL to get query type, tables, field values, etc.. |
Version: 0.1.97 beta
Github: https://github.com/marcocesarato/PHP-Light-SQL-Parser-Class
Author: Marco Cesarato
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.
$lsp = new LightSQLParser("UPDATE Customers as ae SET ContactName = 'Alfred Schmidt', City= 'Frankfurt' WHERE CustomerID = 1;");
OR
$lsp = new LightSQLParser();
$lsp->setQuery("UPDATE Customers as ae SET ContactName = 'Alfred Schmidt', City= 'Frankfurt' WHERE CustomerID = 1;");
How retrieve query method:
$lsp->method();
Output
string(6) "UPDATE"
How retrieve query tables:
$lsp->tables();
Output
array(1) {
[0]=>
string(9) "Customers"
}
How retrieve query fields:
$lsp->fields();
Output
array(2) {
[0]=>
string(11) "ContactName"
[1]=>
string(4) "City"
}
| Method | Parameters | Description | | ----------- | ----------------------------------- | -------------------------------------------------- | | __construct | | Constructor | | setQuery | | Set SQL Query string | | method | param $query<br> return string | Get SQL Query method | | fields | param $query<br> return array | Get Query fields (at the moment only SELECTINSERTUPDATE) | | table | param $query<br> return string | Get SQL Query First Table | | tables | return array | Get SQL Query Tables |
Files |
File | Role | Description | ||
---|---|---|---|---|
Demo (1 file) | ||||
src (1 file) | ||||
composer.json | Data | Auxiliary data | ||
demo.php | Example | Demo | ||
LICENSE | Lic. | License text | ||
lightsqlparser.class.php | Class | Main Class | ||
README.md | Doc. | README |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
71% |
|
|
User Comments (1) | |||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.