Results 1 to 3 of 3

Thread: optimizing tables with php

  1. #1
    Super Moderator subzero's Avatar
    Join Date
    Mar 2006
    Location
    Your Screen.
    Posts
    3,971
    Thanks
    442
    Thanked 379 Times in 180 Posts
    Blog Entries
    7
    Rep Power
    0

    Default optimizing tables with php

    Code:
    <?php
    $db = mysql_connect('localhost','user','password');
    if(!$db) echo "cannot connect to the database";
    mysql_select_db('user_drpl1');
    $result=mysql_query('OPTIMIZE TABLE accesslog,cache,comments,node,users,watchdog;');
    echo mysql_error();
    ?>
    Change user, password and user_drpl1 to reflect your Drupal MySQL username, password and database.



    This will optimize the tables accesslog, cache, comments, node, users and watchdog. Feel free to add or remove tables from the query.



    Once you have inserted the code, save the file. For the purposes of this example, we'll assume that the file is called optimize.php. Once the file is saved in your folder, you can execute it directly from a browser:



    [Only registered and activated users can see links. Click Here To Register...]



    If you get a blank page without any errors, this means that the tables have been successfully optimized



    You can also set a cron job in order to execute the optimization script at regular intervals. The cron job you set should be similar to this:



    php /home/user/public_html/YOURLOGIN/optimize.php



    Make sure you don't set the cron to be executed too often. Once a week should be more than enough to keep your tables optimized

    here is other way doing it

    i like using this way

    each page you place your sql commands like

    like index.php you place

    Code:
    @mysql_query("OPTIMIZE TABLE online") or die(mysql_error());
    @mysql_query("OPTIMIZE TABLE user") or die(mysql_error());
    @mysql_query("OPTIMIZE TABLE forums") or die(mysql_error());
    @mysql_query("OPTIMIZE TABLE status") or die(mysql_error());
    @mysql_query("OPTIMIZE TABLE download") or die(mysql_error());
    @mysql_query("OPTIMIZE TABLE settings") or die(mysql_error());
    i like that way as each user past your site or has a look it optimize the table for you. better then adding cron job's
    Visit: [Only registered and activated users can see links. Click Here To Register...]
    Visit: [Only registered and activated users can see links. Click Here To Register...]
    _______
    SCRIPTS FOR SALE BY SUBZERO
    Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
    FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
    _______
    Info & Tips
    php.net
    w3schools.com

  2. The Following User Says Thank You to subzero For This Useful Post:

    wapmetal (11-04-10)

  3. #2
    Senior Member
    Join Date
    Mar 2009
    Location
    Albania, East Europe
    Posts
    618
    Thanks
    180
    Thanked 54 Times in 27 Posts
    Rep Power
    5

    Default

    thanks sub!
    i am in mobile now, with click "thanks" tomorrow!

  4. #3
    Senior Member wapmetal's Avatar
    Join Date
    Mar 2009
    Location
    guam, USA
    Posts
    616
    Thanks
    82
    Thanked 22 Times in 22 Posts
    Rep Power
    5

    Default

    i'm gonna try this bro
    com site: [Only registered and activated users can see links. Click Here To Register...]
    download site: [Only registered and activated users can see links. Click Here To Register...]
    fb: [Only registered and activated users can see links. Click Here To Register...]

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Database And Tables
    By CyberNet69 in forum Site / Script testing and error fixing
    Replies: 3
    Last Post: 23-02-09, 05:41
  2. Help With Optimizing This Script
    By ReGzBk in forum Site / Script testing and error fixing
    Replies: 3
    Last Post: 15-08-08, 06:25
  3. How To Install Tables For Lavalair
    By matthewdowd in forum Scripts Forum
    Replies: 2
    Last Post: 19-04-07, 17:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19