1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Simple Cron SQL Job

Discussion in 'General PHP and MySQL Discussions' started by rivacom, Oct 8, 2014.

  1. rivacom

    rivacom Active Member

    Hi everyone, I have some code I want to enable for a cron job to update a table based on a custom field. I'm trying to convert my straight PHP script to what I think is Xenforo friendly but I could be wrong. However I seem to be having issues with the insert query, can anyone comment or even let me know if the whole thing has been done wrong? Thanks!


    class twitch_cron {
    protected static 
    $queries = array(
    'deleteQuery' => 'TRUNCATE TABLE `xf_twitch_streams`',
    'userQuery' => 'SELECT * FROM xf_user_field_value WHERE field_id = "twitch" AND field_value <> ""',
    'insertQuery' => 'INSERT INTO `xf_twitch_streams` (twitch_username, twitch_viewers) VALUES ($data[0],$viewer[0])'
        public static function 

    $db XenForo_Application::get('db');
    $db as $user) {
    $twitchuser[] = $user['field_value'];
    $data json_decode(file_get_contents('http://api.justin.tv/api/stream/list.json?channel=' $twitchuser[0]));
    $viewer[0] = $data[0]->channel_count;

Share This Page