[Fwd: Re: [PEAR] Problems with "no database selected" error with DB package]
| From: | Charlene | Date: | Wed, 28 Dec 2005 00:35:38 +0000 |
| Subject: | [Fwd: Re: [PEAR] Problems with "no database selected" error with DB package] | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-22353@lists.php.net to get a copy of this message | ||
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] => databaseIt sure looks like everything is ok there. 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:-- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php$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