You are here: Re: split sql script in queries « PHP Programming Language « IT news, forums, messages
Re: split sql script in queries

Posted by gosha bine on 04/18/07 13:20

On 18.04.2007 15:07 Ben wrote:
> Hi,
>
> To simplify this request, we supposed this following sql script:
>
> "insert into table a values ('me;you','then'); insert into table a
> values ('you;me','so');"
>
> Note the semi-colon ( ; ) in strings for the first field in both
> queries.
>
> How to split that with preg_split() ?
>
> Thanks
>
> Ben
>

hi

I think the regexp code should be something like

$sql =
"insert into table a values ('me;you','then'); insert into table a
values ('you;me','so');"
;

preg_match_all(
"/('(\\\\.|.)*?'|[^;])+/s",
$sql,
$matches);
$stmts = $matches[0];
print_r($stmts);




--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация