Jump to:

22972 Posts in 11596 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » SQL query: Call to a member function execute() on a non-object

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: 386 Views
  • Fraser
    Avatar
    Community Member
    46 Posts

    SQL query: Call to a member function execute() on a non-object Link to this post

    I am trying to execute and return results from the below statement:

    $sqlQuery = new SQLQuery();
    $sqlQuery->setFrom('ListingCategory_Listings');
    $sqlQuery->selectField('*');
    $sqlQuery->addLeftJoin('Listing', '"ListingCategory_Listings"."ListingID" = "Listing"."ID"');
    $sqlQuery->addLeftJoin('SiteTree_Live', '"Listing"."ID" = "SiteTree_Live"."ID"');
    $sqlQuery->addLeftJoin('ListingCategory', '"ListingCategory_Listings"."ListingCategoryID" = "ListingCategory"."ID"');
    $sqlQuery->addLeftJoin('File', '"ListingCategory"."IconID" = "File"."ID"');
    $rawSQL = $sqlQuery->sql();
    return $rawSQL->execute();

    When I output the SQL to my template and run the query through phpmyadmin, results are returned, however I am getting an error "Fatal error: Call to a member function execute() on a non-object" what am I doing wrong here?

  • Fraser
    Avatar
    Community Member
    46 Posts

    Re: SQL query: Call to a member function execute() on a non-object Link to this post

    I sorted this, it was because I was trying to return the execute.

    386 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.