Jump to content

Search the Community

Showing results for tags 'migration truncate'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Ok, so I have need to move some data from one table to another every so often. I use the below code to simply Truncate the target table and then copy a fields from the Source table over. I only have 29 000 or so rows and I've done this type of thing before. My issue is that it's quite slow and when the Count reaches somehwere around 7000 or (easily 4-5minutes), the count seems to start back over at Zero, as though it were looping or something?? ini_set("memory_limit","256M"); set_time_limit(3000); echo "Please wait as the tables are Truncated then Synchronised."; mysql_connect($db_host,$MySqlUN,$MySqlPW); @mysql_select_db($database) or die( "Unable to select databases"); $query =" SELECT ID, Surname, Initials, Forenames FROM MAIN "; $TruncateME = mysql_query("TRUNCATE tblsearchtable ") or die ('Failed to Query Database' . mysql_error()); //TIME TO REBUILD THE TABLE FROM THE MAIN DB $result = mysql_query($query) or die($query); while ($row= mysql_fetch_array($result)) { // Update the DB fields with the Amended content $sqlStatement = "INSERT INTO tblsearchtable (ID, Surname, Initials, Forenames) VALUES ( '".mysql_real_escape_string($row['ID'])."', '".mysql_real_escape_string($row['Surname'])."', '".mysql_real_escape_string($row['Initials'])."', '".mysql_real_escape_string($row['Forenames'])."' )"; // Step 4: MySQL Query //echo $sqlStatement; $NEWresult = mysql_query($sqlStatement) or die ('Failed to Query Database' . mysql_error()); } //Close the db connection mysql_close(); $query='';
×
×
  • 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.