开发者

Calculating the total price of products from different dbs with php

开发者 https://www.devze.com 2023-03-06 14:56 出处:网络
I have several databases with same tables. Anytime a user registers on my app a new database is created for him/her with same tables as all the other dbs.

I have several databases with same tables. Anytime a user registers on my app a new database is created for him/her with same tables as all the other dbs.

Now what I want to do is

  1. calculate the value ie sum total of "price" from table_1(produts) for all the dbs
  2. And add these values from all the databases.

开发者_如何学JAVAThe idea is to show how much transaction pass through my system. so I want to add the total price of each users products together to get the sum of all transaction been carried out on my system and echo it.

I am new to programming so I would appreciate detail explanation of the solution


This does not answer your question.

You should stop now and change your design. There is no reason that you should ever, ever, ever create a new table for every user, let alone a new DB. This is really, really inefficient, resource hungry and will get very complicated very quickly (as you are finding out).

Change your design today to put all your users in a single table in a single database.

0

精彩评论

暂无评论...
验证码 换一张
取 消