Jump to content

i would like to know the most effective way in your opinions, to copy a table and its content using php.


alexandre

Recommended Posts

9 minutes ago, requinix said:

How to do what, exactly? Copy the structure and data of a table to a new table?

yes and after that i would drop and create a new table based on the copied structure to make a new round start from zero. so i would keep a clone of the previous round for historical values and keep going with the events. its just that i need everything to be automated so i need to do it with php

Edited by alexandre
Link to comment
Share on other sites

Actually you need to do it with SQL. PHP can be used to run that SQL, but PHP isn't going to be creating tables or copying data.

If the table is simple and not used frequently then you rename the table and create a new blank one.

If it has things like triggers or is being used a lot then create a blank table like the old one, which I think you said you know how to do, then do an INSERT...SELECT query.

Link to comment
Share on other sites

1 minute ago, requinix said:

Actually you need to do it with SQL. PHP can be used to run that SQL, but PHP isn't going to be creating tables or copying data.

If the table is simple and not used frequently then you rename the table and create a new blank one.

If it has things like triggers or is being used a lot then create a blank table like the old one, which I think you said you know how to do, then do an INSERT...SELECT query.

yeah you are right i could probably make a collumn ,a tiny int based on 1 and 0  and if my conditions are met then the 1 or 0 can be used to target the data to insert.. am i right ?

Link to comment
Share on other sites

1 minute ago, alexandre said:

yeah you are right i could probably make a collumn ,a tiny int based on 1 and 0  and if my conditions are met then the 1 or 0 can be used to target the data to insert.. am i right ?

...why? Do you not want to copy the whole table?

Link to comment
Share on other sites

Just now, requinix said:

...why? Do you not want to copy the whole table?

thats another thing i wanted to ask about performance is it faster to just pull the whole table or to reduce the amount of data processes? i could just aim for the data i want? i am not sure about that anymore but i am trying to see this with a high traffic scale just to ensure that it is prepared to every eventuality .. 

Link to comment
Share on other sites

29 minutes ago, alexandre said:

thats another thing i wanted to ask about performance is it faster to just pull the whole table or to reduce the amount of data processes? i could just aim for the data i want? i am not sure about that anymore but i am trying to see this with a high traffic scale just to ensure that it is prepared to every eventuality .. 

"High traffic" as in being written to frequently? Then you have a small problem of trying to decide what rows in the table you want to archive - after all, a bunch of them are being added all the time.
Or, if it's being read from frequently, how are you going to make sure you don't pulls rows out of the table when something wants to read them?

I feel like you have some questions here that need to be answered before you can do much more...

Link to comment
Share on other sites

1 minute ago, requinix said:

"High traffic" as in being written to frequently? Then you have a small problem of trying to decide what rows in the table you want to archive - after all, a bunch of them are being added all the time.
Or, if it's being read from frequently, how are you going to make sure you don't pulls rows out of the table when something wants to read them?

I feel like you have some questions here that need to be answered before you can do much more...

i am thinking about making the two events running with a timer set for 5 days , then take two days to let people claim their rewards if they didnt when the timer goes on again the prizes will be sent to another participant(i dint figured out yet how to make the balances update automaticly without the user being on the actual page ). so long story short, this weekend with the timer off will be used to make updates and everything that needs to be done like creating a new round for the events. but this is more to give a mental break to the users since all of this looks like gambling games, i dont want people to go addicted ...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.