[PHP-DB] Queries from two databases don't work
Hello, I need query tables that are in two different databases so I use mysql_query() with link_identifier, as I've read in the manual, in order to select in wich DB must be made the query. The problem I have is that the link identifier has no effect. This example doesn't work ?php $conn_1=mysql_pconnect(localhost,usermysql,password); mysql_select_db(DB1, $conn_1); $conn_2=mysql_pconnect(localhost,usermysql,password); mysql_select_db(DB2, $conn_2); // -- (1) $result_t1 = mysql_query(SELECT * FROM `Table1inDB1`,$conn_1); $row_t1 = mysql_fetch_assoc($result_t1); // -- (2) $result_t2 = mysql_query(SELECT * FROM `Table2inDB2`,$conn_2); $row_t2 = mysql_fetch_assoc($result_t2); ? It is as if (1) activates DB2 for all the script an in (2) the query is not made in DB1 but in DB2, even using $conn_1. I have looking in php.ini but I haven't found anything useful. My environment is php 4.4.2, mysql 4.0.18, IIS, W2000. Thanks in advance. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Queries from two databases don't work
Joaquín wrote: Hello, I need query tables that are in two different databases so I use mysql_query() with link_identifier, as I've read in the manual, in order to select in wich DB must be made the query. The problem I have is that the link identifier has no effect. This example doesn't work ?php $conn_1=mysql_pconnect(localhost,usermysql,password); mysql_select_db(DB1, $conn_1); $conn_2=mysql_pconnect(localhost,usermysql,password); mysql_select_db(DB2, $conn_2); // -- (1) RTFM: http://php.net/mysql_pconnect To Quote: First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection. You cannot open two database connections using _pconnect with exactly the same information. You need to use _connect and make sure you specify the $new_link parameter. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] [Fixed] Re: [PHP-DB] Queries from two databases don't work
You cannot open two database connections using _pconnect with exactly the same information. You need to use _connect and make sure you specify the $new_link parameter. In fact I used mysql_connect() at first and I didn't work either, so I tried a lot of different tests and one of them was using mysql_pconnect(). Anyway, yes it was the $new_link parameter. That optional parameters drive me mad. Thank you very much. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] coder needed
Pro-Net have a requirement for ether a full time php/msql coder or a good freelancer. Position is to start within two weeks based in London. If anyone is interested, please contact me 0870 835 6911 or 07900 894 044 Sorry if i'm posting to the wrong list. Danial Subhani -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: Best Practices? [PHP-DB] Queries from two databases
From: Joaquín [EMAIL PROTECTED] I need query tables that are in two different databases mysql_select_db(DB1, $conn_1); mysql_select_db(DB2, $conn_2); $result_t1 = mysql_query(SELECT * FROM `Table1inDB1`,$conn_1); $row_t1 = mysql_fetch_assoc($result_t1); $result_t2 = mysql_query(SELECT * FROM `Table2inDB2`,$conn_2); $row_t2 = mysql_fetch_assoc($result_t2); Although Joaquín said his issue is [Fixed], I write these queries as: SELECT * FROM DB1.TableInDB1 SELECT * FROM DB2.TableInDB2 (with and without link_identifiers I believe), so I was wondering about best practices. I can see if you already have code written without the DB in the FROM clause, it could be easier to have multiple links. I haven't really used multiple links, but I ran into issues with multiple databases and consistently setting the correct DB, so now if I know I'll be using multiple DB's, I just write the query with the DB in the FROM clause. (A prior fix was to select the DB before each query. But if it was already selected, it seemed like a waste {according to my by inspection profiler}. So I started using the DB in the FROM clause.) Are there any recommendations regarding best practices between: 1) using multiple links and table.field (or table) notation versus 2) database.table.field (or database.table) notation? _ Local listings, incredible imagery, and driving directions - all in one place! http://maps.live.com/?wip=69FORM=MGAC01 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DBF + PHP
What errors are you getting? Check file permissions, maybe you can't read/write the file. I get warning: Warning: dbase_open() [function.dbase-open]: unable to open database c:\temp\test.dbf in /usr/local/lappstack-1.1/apache2/htdocs/dbase.php on line 8 In php.ini I have safe_mode=off. Even if I wont simple change a directory by: echo getcwd() . \n; chdir('c:\\temp'); echo getcwd() . \n; I get this warning: /usr/local/lappstack-1.1/apache2/htdocs Warning: chdir() [function.chdir]: No such file or directory (errno 2) in /usr/local/lappstack-1.1/apache2/htdocs/dbase.php on line 5 /usr/local/lappstack-1.1/apache2/htdocs And how you see the directory does't change :( Some propositin? THANKS ALL :) echo getcwd() . \n; chdir('c:\\Przewozy\\BAZY'); echo getcwd() . \n; $db = dbase_open(c:\\Przewozy\\BAZY\\Ceny.dbf, 0); -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DBF + PHP
From: Luke [EMAIL PROTECTED] echo getcwd() . \n; chdir('c:\\temp'); echo getcwd() . \n; chdir('c:\\Przewozy\\BAZY'); echo getcwd() . \n; $db = dbase_open(c:\\Przewozy\\BAZY\\Ceny.dbf, 0); Just a quick guess/suggestion: Single tick quotes ' are taken literally and double tick quotes allow expansion. $aVariable = 0; echo '$aVariable';//$aVariable echo $aVariable;//0 Maybe change the chdir to use double quotes or remove the double backslash? Especially if your dbase_open works with double quotes and the double backslash. _ http://im.live.com/messenger/im/home/?source=hmtextlinkjuly07 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DBF + PHP
On Thu, Jul 19, 2007 at 19:34:34 +0200, Luke wrote: I get this warning: /usr/local/lappstack-1.1/apache2/htdocs Warning: chdir() [function.chdir]: No such file or directory (errno 2) in echo getcwd() . \n; chdir('c:\\Przewozy\\BAZY'); echo getcwd() . \n; You seem horribly confused. Why are you using Windows-style paths (c:\\..) on something that looks to be a un*x server (/usr/local...) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DBF + PHP
Instruct ICC [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] From: Luke [EMAIL PROTECTED] echo getcwd() . \n; chdir('c:\\temp'); echo getcwd() . \n; chdir('c:\\Przewozy\\BAZY'); echo getcwd() . \n; $db = dbase_open(c:\\Przewozy\\BAZY\\Ceny.dbf, 0); Just a quick guess/suggestion: Single tick quotes ' are taken literally and double tick quotes allow expansion. $aVariable = 0; echo '$aVariable';//$aVariable echo $aVariable;//0 Maybe change the chdir to use double quotes or remove the double backslash? Especially if your dbase_open works with double quotes and the double backslash. Thanks, but it did't help :(. I still get the some error. I thing it is something with php configuration ? Some other suggestion? _ http://im.live.com/messenger/im/home/?source=hmtextlinkjuly07 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DBF + PHP
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thu, Jul 19, 2007 at 19:34:34 +0200, Luke wrote: I get this warning: /usr/local/lappstack-1.1/apache2/htdocs Warning: chdir() [function.chdir]: No such file or directory (errno 2) in echo getcwd() . \n; chdir('c:\\Przewozy\\BAZY'); echo getcwd() . \n; You seem horribly confused. Why are you using Windows-style paths (c:\\..) on something that looks to be a un*x server (/usr/local...) Becouse I wont read files, exactly *.dbf, from local machine, not from server. I have no problem with read or changing directory, if database is located on server. Thanks for any suggestion. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Slooooow query in MySQL.
I have a query that I run using mysql that returns about 60,000 plus rows. It's been so large that I've just been testing it with a limit 0, 1 (ten thousand) on the query. That used to take about 10 minutes to run, including processing time in PHP which spits out xml from the query. I decided to chunk the query down into 1,000 row increments, and tried that. The script processed 10,000 rows in 23 seconds! I was amazed! But unfortunately it takes quite a bit longer than 6*23 to process the 60,000 rows that way (1,000 at a time). It takes almost 8 minutes. I can't figure out why it takes so long, or how to make it faster. The data for 60,000 rows is about 120mb, so I would prefer not to use a temporary table. Any other suggestions? This is probably more a db issue than a php issue, but I thought I'd try here first. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DBF + PHP
Becouse I wont read files, exactly *.dbf, from local machine, not from server. I have no problem with read or changing directory, if database is located on server. Thanks for any suggestion. So you are running PHP on your local machine localhost which happens to be a Windows machine, and also was compiled with the --enable-dbase option? Are you only dealing with 1 machine and it is not a UNIX flavor? If you had a web page served from a UNIX box with an html file field (like Upload this file) that you view from a browser on a Windows box, which browses the local machine, the different file path styles could make sense. Or if dbase_open could connect to a remote server like fopen. If you are trying to use dbase_open on your local machine to connect to a remote machine's test.dbf, it looks like this function does not work across servers. Maybe use fopen and friends to get the remote file? _ http://imagine-windowslive.com/hotmail/?locale=en-usocid=TXT_TAGHM_migration_HM_mini_2G_0507 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DBF + PHP
$db = dbase_open(c:\\Przewozy\\BAZY\\Ceny.dbf, 0); Or if you can map the drive, then you should be able to use a path like above using the mapped drive or \\server\volume\path\test.dbf Can you call up the file in Windows Explorer? _ http://imagine-windowslive.com/hotmail/?locale=en-usocid=TXT_TAGHM_migration_HM_mini_pcmag_0507 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Slooooow query in MySQL.
Seeing the query would help. Are you using sub-queries? I believe that those can make the time go up exponentially. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada College www.wnc.edu 775-445-3326 P.S. Please note that my e-mail and website address have changed from wncc.edu to wnc.edu. On Jul 19, 2007, at 2:19 PM, Rob Adams wrote: I have a query that I run using mysql that returns about 60,000 plus rows. It's been so large that I've just been testing it with a limit 0, 1 (ten thousand) on the query. That used to take about 10 minutes to run, including processing time in PHP which spits out xml from the query. I decided to chunk the query down into 1,000 row increments, and tried that. The script processed 10,000 rows in 23 seconds! I was amazed! But unfortunately it takes quite a bit longer than 6*23 to process the 60,000 rows that way (1,000 at a time). It takes almost 8 minutes. I can't figure out why it takes so long, or how to make it faster. The data for 60,000 rows is about 120mb, so I would prefer not to use a temporary table. Any other suggestions? This is probably more a db issue than a php issue, but I thought I'd try here first. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] RE: Best Practices? [PHP-DB] Queries from two databases
Instruct ICC wrote: From: Joaquín [EMAIL PROTECTED] I need query tables that are in two different databases mysql_select_db(DB1, $conn_1); mysql_select_db(DB2, $conn_2); $result_t1 = mysql_query(SELECT * FROM `Table1inDB1`,$conn_1); $row_t1 = mysql_fetch_assoc($result_t1); $result_t2 = mysql_query(SELECT * FROM `Table2inDB2`,$conn_2); $row_t2 = mysql_fetch_assoc($result_t2); Although Joaquín said his issue is [Fixed], I write these queries as: SELECT * FROM DB1.TableInDB1 SELECT * FROM DB2.TableInDB2 (with and without link_identifiers I believe), so I was wondering about best practices. If you only ever deal with mysql then you'll be fine. Other databases may or may not support this feature. The other problem could be user 'A' has access to DB1 but no access to DB2. So you have to connect as user 'B' to be able to read from DB2. So - as usual - it depends is the answer. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Slooooow query in MySQL.
Rob Adams wrote: I have a query that I run using mysql that returns about 60,000 plus rows. It's been so large that I've just been testing it with a limit 0, 1 (ten thousand) on the query. That used to take about 10 minutes to run, including processing time in PHP which spits out xml from the query. I decided to chunk the query down into 1,000 row increments, and tried that. The script processed 10,000 rows in 23 seconds! I was amazed! But unfortunately it takes quite a bit longer than 6*23 to process the 60,000 rows that way (1,000 at a time). It takes almost 8 minutes. I can't figure out why it takes so long, or how to make it faster. The data for 60,000 rows is about 120mb, so I would prefer not to use a temporary table. Any other suggestions? This is probably more a db issue than a php issue, but I thought I'd try here first. Sounds like missing indexes or something. Use explain: http://dev.mysql.com/doc/refman/4.1/en/explain.html -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php