Php database switching problems

Source: Internet
Author: User
Php switches the database and online RT. my goal is to change the database link in one place and use the new link when querying other pages .. Now I enter a query page tttt. php: use the default link to query 3 Data. Then, select another region from the drop-down list, when I select the drop-down box, I use ajax to switch the database link from the background. then I enter the query page ttt. php, the data is still the data of the previous database... In addition to switching php databases
RT, my goal is to change the database link in one place and use the new link when querying other pages ..
Now, I enter tttt. php on the query page and use the default link to query 3 data records.
Then, I select other regions from the drop-down list. when I select the drop-down list, I used ajax to switch the database link from the background.
At this time, I will go to the query page ttt. php. The data is still the data of the previous DB...

In addition to listing the databases in each region for switchover, is there any better method? (Because the region is dynamically increased)

Require_once dirname (_ FILE _). '/../common/DbSingleHelper. php ';
Require_once dirname (_ FILE _). '/../svr_yunwei_config.php ';
$ DbsingleHelper = DBSingleHelper: singleton ();
$ SQL = 'SELECT count (*) as ct from login_log ';
$ Res = $ dbsingleHelper-> doSql ($ SQL );
Echo "number of items found:". $ res [0] ['CT ']."
";
// $ DbsingleHelper-> changeDbLink ("xxxx", "xxx ");
// $ R = $ dbsingleHelper-> doSql ($ SQL );
// Echo "new count:". $ r [0] ['CT '];

Is correct, but the problem is that the switch action is triggered by the operator. on another page, after the switch is triggered on another page, the result of this query is still the data of the previous DB...
It means that after I switch the db in one place, I cannot change the rest of the page... Even if a single column is used
Please advise...

PHP database industry data

Share:


------ Solution --------------------
If two pages are scheduled through a url, the same connection cannot be used.
When the program ends, the database is closed.

However, you can pass the object field between two pages through serialization.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.