English 中文(简体)
PHP MySQL Constant or Super Global
原标题:PHP MySQL Constant or Super Global

I m从事一个PHP/MySQL项目,该项目需要利用多个数据库。 此前,当我只需要查阅一个数据库时,我确定了数据库服务器、用户名称、密码和名称的固定点(DB_SERVER, DB_USER, ect...)。 然而,现在我的申请正在使用多个数据库,我不能再用固定数字来界定这一信息。

我有一个数据库级,处理每当笔书操作时的开关和结关;我的sql_link(DB_SEReck、DB_USER、DB_MAPS)和我的sql_select_db功能均来自这一类别。

根据哪一个数据库,应用需要与哪一个数据库连接,使用超级全球变量确定适当的连接信息是否安全? 我是否应该把链接信息作为论据传递给我的数据库类别? 或者,我是否应该完全重新考虑这一点?

希望提出建议!

问题回答

如果我把链接信息作为论据传递给我的数据库类别

是的。 数据库班只应了解数据库:如何连接、如何查询等。 配置来源及其即时性不是其业务





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签