astymore
astymore

Reputation: 175

Calculating the total price of products from different dbs with php

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.

The 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

Upvotes: 2

Views: 424

Answers (1)

Toby Allen
Toby Allen

Reputation: 11213

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.

Upvotes: 3

Related Questions