Subject Re: [firebird-php] Executing SQL scripts via PHP5 for FB 1.5
Author Milan Babuskov
Myles Wakeham wrote:
> This is the behavior I am aiming at having with Firebird, however I'm not
> sure what PHP functions are available (if any) to have a full script
> execute. I can see the normal connect, query, disconnect stuff and use that
> without any problems. But what if one wants to execute a complete SQL
> script? Do you have to shell out to ISQL to do this, or is there a better
> way with PHP to do it from within a traditional PHP or IBASE command?

You should either invoke isql or write a parser to separate statements
and run them. isql scripts contain various SET xxx statements that you
might 'emulate' and there are also COMMIT and similar statements. It's
tricky (I know since we support a subset of isql commands in FlameRobin)
but doable. It all depends on the script origin (do you make it, or
users can supply their own). If you make it, you can make sure it's
'clean' of any things you don't support in your parser.

Simplest way to parse a script is to use SET TERM stuff like isql and
just 'cut' the statements where terminator character appears. You also
need to skip out comments (stuff between /* and */ and between -- and
newline characters) and single/double quoted strings. As I said, it is
not trivial, but one could surely write such a parser in a day.

Good luck

--
Milan Babuskov
http://www.flamerobin.org