Recommend this page to a friend! |
Download |
Info | Example | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 242 | All time: 8,018 This week: 38 |
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.. |
<?php
|
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 (7) |
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 |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
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.