Jump to content

[PAID] - Daily task to drop ip pages db fields to csv file


Phillyman

Recommended Posts

I used to have this being handled by a cron job and some php code, but it stopped working when I upgraded my php level. Basically I just have some code that drops out certain fields in my IP Pages database to a dat file that is essentially just a csv file. Would be great if I could have this run from within IPB in the tasks, rather than a cron job. It would be super great if this task only ran when that IP content Database had a change made to it.

Here is the old code....

 

<?php
    $fh = fopen("/home/mysite/public_html/dats/magazines.dat", "w");
    $con = mysql_connect("localhost","mysite_readoly","superpass");
    mysql_select_db("mysite_db", $con);

    /* insert field values into data.txt */

    $result = mysql_query("SELECT `field_129`, `field_131`,`field_132`,`field_26` FROM `cms_custom_database_5` WHERE `field_129` <> '' AND `field_131` <> '' AND `field_132` <> '' AND `field_26` <> '' ");   
    while ($row = mysql_fetch_array($result)) {          
        $num = mysql_num_fields($result) ;    
        $last = $num - 1;
        for($i = 0; $i < $num; $i++) {            
            fwrite($fh, $row[$i]);                       
            if ($i != $last) {
                fwrite($fh, ",");
            }
        }                                                                 
        fwrite($fh, "\n");
    }
    fclose($fh);
?>

 

JOB HAS BEEN TAKEN.

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
×
×
  • Create New...