Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

I am having trouble with a new plugin I'm creating - what's wrong with this sql statement.

peregrineperegrine MVP
edited October 2012 in Vanilla 2.0 - 2.8

I tried using this in

public function PurgeLogCount($delDays){
  $SQL = Gdn::SQL();
    $SQL->Delete
            ->From(`GDN_Log`)
            ->Where("DATEDIFF(CURDATE( ) ,`RecordDate` )") > '30'
            ;
}


I can run this in phpmyadmin.

DELETE FROM `GDN_Log` WHERE (
DATEDIFF( CURDATE( ) , `RecordDate` )
) > '30'

I get this error

Fatal error: Call to a member function From() on a non-object in /var/www/vanilla/plugins/CleanLog/default.php on line 65

line 65 is ->From(GDN_Log) from above.

any tips @Todd

I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Comments

  • ToddTodd Chief Product Officer Vanilla Staff

    I'd do this like:

    $SQL->Delete('Log', array('RecordDate <' => Gdn_Format::ToDateTime(strtotime('-30 days'))));
    
  • Perfect. thanks. When you know how to do something it is so much simpler :).

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • I added this plugin...
    http://vanillaforums.org/addon/cleanlog-plugin

    @Todd - thanks for the help above - additionsal problem here...

    However,
    I am trying to add images to the plugin for descriptive purposes on the vanillaforums site

    if I do upload screen which goes to this link

    http://vanillaforums.org/addon/addpicture/1010

    I get this error

    Error 503 Service Unavailable

    Service Unavailable
    Guru Meditation:

    XID: 175486247

    Varnish cache server

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • I reduced the image sizes to less than 15kb and I am able to upload screens
    (any bigger than that and I get the above error- bandwidth timing issue)

    if I do upload screen which goes to this link

    http://vanillaforums.org/addon/addpicture/1010

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • ToddTodd Chief Product Officer Vanilla Staff

    @Tim?

  • TimTim Operations Vanilla Staff

    @peregrine

    I just tested for myself and I'm having no problems at all uploading even large files. What OS and Browser are you using? And could you PM me your IP?

    It would also help if you could use a browser like Chrome and watch your network panel, and paste me the Request and Response headers that you get from the upload attempt. Probably also in a PM.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • thanks @Tim

    I sent you the message with details. I hope you have success solving this issue for low-bandwidth users, since it really limits the ability to show any kind of decent image on the add-on site or to upload attachment on this thread.

    don't know if these are related. But
    I also had timing issues with low bandwidth with some rss feed plugins, I had to change some timing as described here...

    http://vanillaforums.org/discussion/comment/164509/#Comment_164509

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.