jasny / persist-sql-query

The best and most complete query builder/parser for MySQL (PHP)
MIT License
33 stars 8 forks source link

Implement splitValues to get values of INSERT INTO ... VALUES ... statement #5

Closed keldrox closed 4 years ago

keldrox commented 4 years ago

I would very much like this functionality to exist

thanks!!

jasny commented 4 years ago

Implemented in v3 (alpha1).

use Jasny\Persist\SQL\Query;

$query = new Query("INSERT INTO foo VALUES (1, 'test', 22), (2, 'bar', NULL)", 'mysql');
$values = $query->getValues(Query::UNQUOTE); // [ [1, 'test', 22], [2, 'bar', null] ]

Please note that the project name has changed to jasny/persist-sql-query and the namespace has also changed..

keldrox commented 4 years ago

getValues not working yet for an UPDATE query?

Thanks for your wonderful work

jasny commented 4 years ago

An update query doesn't have a VALUES section. Use getSet() instead.