Author Topic: Temporary to Permanent database  (Read 417 times)

0 Members and 1 Guest are viewing this topic.

Offline unknown87Topic starter

  • Irregular
  • Posts: 42
    • View Profile
Temporary to Permanent database
« on: November 16, 2008, 05:21:41 PM »
Hi

I have a temporary database and permanent database and I want to move data from the temporary database to the permanent database in ID order.  I want to move one row at a time every 5 minutes.

How can I acheive this?

This is what I have so far:

Code: [Select]
SELECT id FROM temporary ORDER BY id LIMIT 1;
INSERT INTO permanent SELECT * FROM temporary WHERE id = $id
DELETE FROM temporary WHERE id = $id

Thanks In Advance


Offline Mchl

  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,582
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • FlingBits
Re: Temporary to Permanent database
« Reply #1 on: November 16, 2008, 05:23:08 PM »
Do you have a possibility to run cron jobs on your server?
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Flingbits tutorials | Class Autoloading

Offline unknown87Topic starter

  • Irregular
  • Posts: 42
    • View Profile
Re: Temporary to Permanent database
« Reply #2 on: November 16, 2008, 05:28:31 PM »
no but i'm but looking to switch hosts which supports cron jobs in the near future.

is there a way to acheive without using crons?

Offline Mchl

  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,582
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • FlingBits
Re: Temporary to Permanent database
« Reply #3 on: November 16, 2008, 05:45:40 PM »
Not with PHP.

Well.. you could trigger database operations whenever someone enters your site, but it would be dependent on your site traffic.
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Flingbits tutorials | Class Autoloading

Offline unknown87Topic starter

  • Irregular
  • Posts: 42
    • View Profile
Re: Temporary to Permanent database
« Reply #4 on: November 16, 2008, 05:57:23 PM »
I can't see that working for me.

Is it possibe with javascript/ajax?

Offline Mchl

  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,582
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • FlingBits
Re: Temporary to Permanent database
« Reply #5 on: November 16, 2008, 05:59:49 PM »
Now that you mention it... It possibly could... You'd have to have a webpage, that would send requests to a php script every 5 minutes... The problem would appear if you loose your internet connection (or switch your PC off)
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Flingbits tutorials | Class Autoloading

Offline Maq

  • Global Moderator
  • 'Insane!'
  • *
  • Posts: 11,004
  • Gender: Male
    • View Profile
    • Top Ecigs Reviews
Re: Temporary to Permanent database
« Reply #6 on: November 16, 2008, 08:29:57 PM »
Yes you can.  You should write a recursive function that performs the database operations.  At the end just call sleep(300).  Sleep delays execution, 300 is in seconds = 5 mins.
Electronic Cigarette Reviews - Smoking alternatives, find YOUR ecig!
ini_set ("display_errors""1");
error_reporting(E_ALL);

Offline Mchl

  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,582
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • FlingBits
Re: Temporary to Permanent database
« Reply #7 on: November 17, 2008, 02:52:29 AM »
Recusive? I don't really know PHP internals, but most other languages use stack to keep track of recursion nesting. Making such function recursive will most likely crash the script sooner or later.
If anything this could be done in an infinite while loop. Also time execution timer should be set up high enough and reset in each loop pass.
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Flingbits tutorials | Class Autoloading

Offline unknown87Topic starter

  • Irregular
  • Posts: 42
    • View Profile
Re: Temporary to Permanent database
« Reply #8 on: November 17, 2008, 02:22:25 PM »
how can I make this work with an infinite while loop - can anyone help me with this?

thanks in advance