Re: howto run sql script with php?
| From: | Ashley Sheridan | Date: | Sun, 13 Jun 2010 11:14:53 +0000 |
| Subject: | Re: howto run sql script with php? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-306084@lists.php.net to get a copy of this message | ||
On Sun, 2010-06-13 at 12:52 +0200, Stephan Ebelt wrote:
> On Sun, Jun 13, 2010 at 11:29:14AM +0200, Peter Lind wrote:
> > On 13 June 2010 11:05, Stephan Ebelt <ste@shared-files.de> wrote:
> > > Hello,
> > >
> > > I am trying to run a .sql script produced with mysql-dump from a php script but
> > > failed to find a rudimentary robust solution yet.
> > >
> > > mysql_query() can only run one query at a time. Thus its necessary to somehow
> > > parse the input file and separate the queries... which is difficult since the
> > > syntax can be quite complex.
> > >
> >
> > Use mysqli - it supports running multiple queries at once.
>
> sometimes its as easy as that. I'll give it a try.
>
> thanks,
> stephan
>
>
Why do you have to use PHP at all to do this? You could run the query
directly at the MySQL console.
Failing that, why not use a tool such as phpMyAdmin, which will do all
the hard work for you?
Thanks,
Ash
http://www.ashleysheridan.co.uk