我可以使用这个数据库包装类来连接两个以上的数据库吗
我正在使用这个数据库包装类 http://www.ajaxray.com/blog/2009/08/29/simple-php-pdo-wrapper-light-static-easy-to-use/
我可以使用这个数据库吗用于从一个数据库获取数据并将其插入到另一个数据库的包装类。
如果是的话我应该如何使用它?
例如我想执行以下查询。
echo $select_resellerData = "select * from resellerDetailsEntry where date_format(updatedon,'%Y-%m-%d')='".$date_var.str_pad($i, 2, "0", STR_PAD_LEFT)."'";
$fetch = querytobeexecutedfrom_A_Db($select_resellerData);
while($row_reseller = mysql_fetch_array($fetch))
{
//echo $row_reseller['alloctype'];
##-------------------------------------------Insert into reseller dashboard for each reseller-------------------------------##
$insert_into ="insert into tbl_reseller_dashboard_intermediate set
firstname ='".$row_reseller['firstname']."',
lastname ='".$row_reseller['lastname']."',
mobile ='".$row_reseller['mobile']."',
email ='".$row_reseller['email']."',
citybelongsto ='".$row_reseller['citybelongsto']."',
cityoptedfor ='".$row_reseller['cityoptedfor']."',
tmecode ='".$row_reseller['tmecode']."',
tmename ='".$row_reseller['tmename']."',
updatedon ='".$row_reseller['updatedon']."',
apptype ='".$row_reseller['apptype']."',
empparent='".$row_reseller['data_city']."',
entrydate ='".$date_var.str_pad($i, 2, "0", STR_PAD_LEFT)."'";
$run=querytobeexecutedfrom_B_Db($insert_into);
}
使用此数据库包装类将如何执行 querytobeexecutedfrom_A_Db 和 querytobeexecutedfrom_B_Db?
I am using this database wrapper class http://www.ajaxray.com/blog/2009/08/29/simple-php-pdo-wrapper-light-static-easy-to-use/
Can i use this Database wrapper class for taking data from one database and insert to other .
If yes then how should i use it ?
e.g. i want to execute following query .
echo $select_resellerData = "select * from resellerDetailsEntry where date_format(updatedon,'%Y-%m-%d')='".$date_var.str_pad($i, 2, "0", STR_PAD_LEFT)."'";
$fetch = querytobeexecutedfrom_A_Db($select_resellerData);
while($row_reseller = mysql_fetch_array($fetch))
{
//echo $row_reseller['alloctype'];
##-------------------------------------------Insert into reseller dashboard for each reseller-------------------------------##
$insert_into ="insert into tbl_reseller_dashboard_intermediate set
firstname ='".$row_reseller['firstname']."',
lastname ='".$row_reseller['lastname']."',
mobile ='".$row_reseller['mobile']."',
email ='".$row_reseller['email']."',
citybelongsto ='".$row_reseller['citybelongsto']."',
cityoptedfor ='".$row_reseller['cityoptedfor']."',
tmecode ='".$row_reseller['tmecode']."',
tmename ='".$row_reseller['tmename']."',
updatedon ='".$row_reseller['updatedon']."',
apptype ='".$row_reseller['apptype']."',
empparent='".$row_reseller['data_city']."',
entrydate ='".$date_var.str_pad($i, 2, "0", STR_PAD_LEFT)."'";
$run=querytobeexecutedfrom_B_Db($insert_into);
}
How querytobeexecutedfrom_A_Db and querytobeexecutedfrom_B_Db will be executed with the use of this database wrapper class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,您不能这样做,因为您使用的包装器使用静态函数来分配当前数据库。这意味着在包装器内部您设置了一个用于设置数据库的变量,并且如果您创建包装器的另一个实例,则该变量不会更改。要解决此问题,您需要更改包装器(如果您知道自己在做什么)或使用另一个包装器。
No, you cannot do this, because the wrapper you use uses a static function to assign the current database. This means that inside the wrapper you set a variable that sets your database and that variable doesn't change if you create another instance of the wrapper. To solve this you need to change the wrapper (if you know what you're doing) or use another wrapper.