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

First Add-on help with TABLE_PREFIX

Discussion in 'XenForo Development Discussions' started by dbembibre, Jul 3, 2013.

  1. dbembibre

    dbembibre Active Member

    Im developing a simple add-on to close threads in certain forums based in the last post date.
    The add-on work perfect, if i remove the table_prefix but i don't know how to have access to the table_prefix constant like in vBulletin.
    Last thing is how can log a error to inform that the cron task was executed well or bad ??
    I comment the code with my questions, thanks a lot for your help.

    class CloseThreadCron_CronEntry
    /*Clase para cerrar temas automaticamente basado en la ultima fecha de publicacion*/
    public static function runCloseThreads()
    $options XenForo_Application::get('options');
    $CloseInForums $options->mtcCloseInForums;
    $CloseTime    $options->mtcFromTime//days passed from last post
    if (!empty($CloseInForums) && $CloseTime>0)
    $forumsToClose ' nodeid NOT IN ('.$CloseInForums.')';
    $SQL ="UPDATE ' . TABLE_PREFIX . 'thread SET open=0 WHERE open = 1 AND sticky = 0"
    ' AND last_post_date <= ' intval(time() - (60 60 24 $CloseTime));
                  //Query output
                  //UPDATE ' . TABLE_PREFIX . 'thread SET open=0 WHERE open = 1 AND sticky = 0 nodeid NOT IN (7,101,31,30) AND lastpost_date <= 1367691823"
    $db XenForo_Application::get('db');
    //how log a error log to say "Close cron threads executed correctly" ??
                  //need to close the connection ??
  2. xf_phantom

    xf_phantom Well-Known Member

    there's no dynamic table prefix in xenforo

    all original xenforo tables start ATM always with xf_ => use xf_thread in your query
    Last edited: Jul 3, 2013
  3. dbembibre

    dbembibre Active Member

    Thanks a lot for your quick reply !!

Share This Page