Jump to:

23483 Posts in 18965 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Couldn't run query: Query was empty

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 869 Views
  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Couldn't run query: Query was empty Link to this post

    I want to increase the value of the Counter (an integer) by one.

    Here is the SQL:

    UPDATE `Article` set `Counter` = `Counter` + 1 where `ID` = '12345"

    But when I try to use my SQL with SQLQuery(), I get an error: "Couldn't run query: Query was empty"

    $sqlQuery = new SQLQuery();
    $sqlQuery->sql = "UPDATE `Article_Live` set `Counter` = `Counter` + 1 where `ID` = '". $this->ID ."'";
    $sqlQuery->execute();

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Couldn't run query: Query was empty Link to this post

    how about DB::query(); instead?

  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Re: Couldn't run query: Query was empty Link to this post

    That works, thanks.

    869 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.