Re: [Fwd: Re: [PEAR] Problems with "no database selected" error with DB package]
| From: | Justin Patrin | Date: | Fri, 30 Dec 2005 20:21:34 +0000 |
| Subject: | Re: [Fwd: Re: [PEAR] Problems with "no database selected" error with DB package] | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-22392@lists.php.net to get a copy of this message | ||
On 12/27/05, Charlene <cwemagazines@charter.net> wrote:
> If I didn't print out the contents of the db_mysql object just before I
> execute the querey, I'd wonder too. But if you look at the following:
>
> (from my original post)...
> [dsn] => Array ( [phptype]
> > => mysql [dbsyntax] => mysql [username] => username [password] =>
> > password [protocol] => [hostspec] => localhost [port] => [socket]
> > => [database] => database ) [autocommit] => 1 [transaction_opcount]
> > => 0 [_db] => database
>
> It sure looks like everything is ok there.
>
This really has nothing to do with it. It's only the internal storage
of the DSN. It doesn't show whether a database is selected. As Joe
Stump said, make sure you're not dieconnecting anywhere. Also, of
course, make sure it's connecting ok.
Does this happen on your first query or on a subsequent one?
> Charlene
>
> -------- Original Message --------
> Subject: Re: [PEAR] Problems with "no database selected" error with DB
> package
> Date: Tue, 27 Dec 2005 16:02:03 -0800
> From: Joe Stump <joe@joestump.net>
> To: Charlene <cwemagazines@charter.net>
> CC: PEAR general list <pear-general@lists.php.net>
> References: <43B1D575.9080304@charter.net>
>
>
>
> I just had this happening to me and figured out the problem was that
> I had my database class disconnecting in my class's destructor, which
> resulted in the next query being boned. Make sure you're not
> disconnecting from the database anywhere.
>
> --Joe
>
> On Dec 27, 2005, at 3:59 PM, Charlene wrote:
>
> > I am using a class to do a query. It works fine the first time,
> > but hte next time, I get the "no database selected error. When I
> > use this line:
> >
> > print_r($this->dbh);
> >
> > The following is displayed:
> >
> > db_mysql Object ( [phptype] => mysql [dbsyntax] => mysql [features]
> > => Array ( [limit] => alter [new_link] => 4.2.0 [numrows] => 1
> > [pconnect] => 1 [prepare] => [ssl] => [transactions] => 1 )
> > [errorcode_map] => Array ( [1004] => -15 [1005] => -15 [1006] =>
> > -15 [1007] => -5 [1008] => -17 [1022] => -5 [1044] => -26 [1046] =>
> > -14 [1048] => -3 [1049] => -27 [1050] => -5 [1051] => -18 [1054] =>
> > -19 [1061] => -5 [1062] => -5 [1064] => -2 [1091] => -4 [1100] =>
> > -21 [1136] => -22 [1142] => -26 [1146] => -18 [1216] => -3 [1217]
> > => -3 ) [connection] => Resource id #21 [dsn] => Array ( [phptype]
> > => mysql [dbsyntax] => mysql [username] => username [password] =>
> > password [protocol] => [hostspec] => localhost [port] => [socket]
> > => [database] => database ) [autocommit] => 1 [transaction_opcount]
> > => 0 [_db] => database [_debug] => [_default_error_mode] =>
> > [_default_error_options] => [_default_error_handler] =>
> > [_error_class] => DB_Error [_expected_errors] => Array ( )
> > [fetchmode] => 3 [fetchmode_object_class] => stdClass
> > [was_connected] => [last_query] => [options] => Array
> > ( [result_buffering] => 500 [persistent] => [ssl] => [debug] => 0
> > [seqname_format] => %s_seq [autofree] => [portability] => 0
> > [optimize] => performance ) [last_parameters] => Array ( )
> > [prepare_tokens] => Array ( ) [prepare_types] => Array ( )
> > [prepared_queries] => Array ( ) )
> >
> > It looks like the database is selected. This is my query line:
> >
> > $result = $this->dbh->query($statement);
> >
> > What am I doing anything wrong?
> >
> > Charlene
> >
> > --
> > PEAR General Mailing List (http://pear.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
--
Justin Patrin