|
Posted by petersprc on 10/21/06 22:22
Try http://pear.php.net/package/SQL_Parser
josh.23.french wrote:
> Does anyone have a regex (or knows how to make one) that will get the
> parts of an sql statement?
>
> $sql = "SELECT (* or 'id, username, etc') FROM `(tablename)`, [WHERE
> `id` = 1 and `username` = ".$username."][LIMIT (#)]"
>
> it should return the following array:
>
> $returnd_val = array(
> 'fields'=>''(* or 'id, username, etc')",
> 'table'=>"(tablename)",
> 'where'=>"(`id` = 1 and `username` = \"joe user\")",
> 'limit'=>"1"
> );
>
> A similar regex for update, delete, and insert would help too ;)
Navigation:
[Reply to this message]
|