Re: AGONIZING Mysql Select DB issue.
| From: | Thomas Deliduka | Date: | Mon, 18 Aug 2003 13:21:43 +0000 |
| Subject: | Re: AGONIZING Mysql Select DB issue. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-29937@lists.php.net to get a copy of this message | ||
As I mentioned your suggestion here does work, however while the example was
simple, the application is very extensive and changing every SQL call is not
possible.
On 8/17/03 4:56 PM this was written:
>
> Try using the SQL to select which database.
>
> example, instead of:
>
> select * from table1
>
> use:
>
> select * from database1.table1
>
> if that works, and the php command doesn't that may mean the the mysql client
> lib is broken, although, I've been using it with mysql 4 and it seems to work
> fine.
>
> -Micah
>
>
> On Sunday 17 August 2003 1:49 pm, Thomas Deliduka wrote:
>> I'm not making two connections, I'm making one and only one call to
>> mysql_connect. Also, there is no way in that function as per the
>> definition page of it (http://us3.php.net/mysql_connect) to have the
>> database selected as per your example below.
>>
>> With my connection though, when I do:
>> $dbh = Mysql_connect(blah, blah, blah)
>> Mysql_select_db("db1")
>>
>> I do call:
>> Mysql_query("query", $dbh);
>>
>> For some reason even though I am calling mysql_select_db("db1") it is
>> latching onto the first available database it has access to (or not as the
>> case/permissions may be) and chooses "db2" instead.
>>
>> I don't know why, connecting to the MySQL 3.23 it selects the right
>> database, connecting to the Mysql 4.x server it doesn't allow a selecting
>> of the table even though I do the select function and it returns true as it
>> was selected properly.
>>
>> On 8/16/03 12:23 AM this was written:
>>> If you are doing this:
>>>
>>> $dbh = mysql_connect("db1", blah blah blah);
>>> $dbh2 = mysql_connect("db2", blah blah blah);
>>>
>>> Then
>>>
>>> $r = mysql_query("select * from mytable");
>>>
>>> will use the db2 connection, because it is the most recent. However, if
>>> you do this:
>>>
>>> $r = mysql_query("select * from mytable", $dbh);
>>>
>>> it will use the first connection, as specified in the handle that is
>>> passed back by mysql_connect. mysql_query uses the most recent
>>> connection by default; you can override this action by specifying which
>>> DB handle to use for a given query. Replace $dbh with $dbh2 to select
>>> from tables on the second database.
>>>
>>> Peter
>>>
>>> On Fri, 15 Aug 2003, Thomas Deliduka wrote:
>>>> Here's the stats:
>>>>
>>>> Two servers:
>>>>
>>>> Server 1, Mysql 4.0.12, PHP 4.3.2, apache 1.3.27
>>>> Server 2, Mysql 4.0.14, PHP 4.3.2, apache 1.3.27
>>
>> --
>>
>> Thomas Deliduka
>> IT Manager
>> -------------------------
>> Xenocast
>> Street Smart Media Solutions
>> http://www.xenocast.com/
>
--
Thomas Deliduka
IT Manager
-------------------------
Xenocast
Street Smart Media Solutions
http://www.xenocast.com/