I have been trying use php's preg_split to rewrite mysql's sql insert statement string into general format, for instance:
INSERT INTO `table_name`
SET `col1`=123, `col2`='That''s a ''test case'', and that''s too.'
Expected Result:
Array[0]='col1'
Array[1]=123
Array[2]='col2'
Array[3]='That''s a ''test case'', and that''s too.'
So, I can use the result array to write the sql into the following:
Insert into table_name (col1, col2)
values (123, 'That''s a ''test case'', and that''s too.');
Obviously the simple function like preg_split('/,/', $source) won't work in all cases. I am wondering if there is any better way to do this? Thanks in advance.