Re: mysql.php - create database issue
| From: | george at mail dot zoomedia dot com | Date: | Wed, 21 Aug 2002 15:30:01 +0000 |
| Subject: | Re: mysql.php - create database issue | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-2168@lists.php.net to get a copy of this message | ||
I just installed the latest CVS version of the DB class, and the bug does
indeed go away. Thanks for the quick response. In the future, I'll
remember to take a look at the CVS versions since it looks like they're a
little behind the distributions.
Thanks again,
George
On Tue, 20 Aug 2002, Eric wrote:
>
> I agree that the behavior you describe is a bug. I can't seem to
> reproduce this error from the CVS version of the DB class, nor from the
> latest release of the DB class. I can reproduce the problem from the
> 4.2.2 install. It's possible that this has been fixed already. From the
> CVS repository, I see:
>
> Tue Jun 18 20:41:06 2002 (2 months ago)
> Allow connect/use the MySQL driver without specifying any database
>
> as v1.5 of the mysql.php distribution.
>
> I suppose that it's possible that it didn't make it into the 4.2.2 release
> which was about a month later. Go ahead and download the latest release
> of the DB module (v 1.3) and that should correct your problem.
>
> eric
>
> On Tue, 20 Aug 2002 george@mail.zoomedia.com wrote:
>
> > Hi,
> >
> > If I create a DSN and try to use PEAR to create a new MySQL database using
> > code like this:
> >
> > <?
> > INI_SET('include_path', ".:/usr/local/lib/php");
> > require_once('DB.php');
> > $db = DB::connect("mysql://user:password@localhost");
> > $sql="create database mydatabase";
> > $result = $db->query($sql);
> > if (DB::isError ($result)) die ("Error... :" . $result->getMessage () .
> > "\n");
> > ?>
> >
> > I get the error: 'No Database Selected'
> >
> > This seems to be the case with the following version of DB/mysql.php:
> > mysql.php,v 1.89.2.1 2002/04/09 19:04:14
> >
> > which I think is the version that ships with PHP 4.2.2
> >
> > However, if I use a version of DB/mysql.php from an earlier distro such
> > as:
> > mysql.php,v 1.69.2.3 2001/11/13 01:26:42
> >
> > it works just fine.
> >
> > Obviously, the problem is that the newer version is complaining that I
> > haven't specified a database in my DSN. However, the older version seems
> > more forgiving in this respect, and the newer functionality is arguably
> > buggy because the PEAR code is basically an abstraction for the following
> > native MySQL code:
> >
> > <?
> > mysql_connect("localhost","user","password");
> > $sql="create database mydatabase";
> > mysql_query($sql);
> > ?>
> >
> > Notice, no mysql_select_db() call was needed for the above to work, nor
> > should such a call be required when the action is not database dependent
> > (like CREATE DATABASE)
> >
> > Any thoughts on whether mysql.php should be modified to work the way it
> > used to?
> >
> > Regards,
> > George Mandella
> > george at zoomedia dot com
> >
> >
> > --
> > PEAR General Mailing List (http://pear.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
>