microsoftdotcom Posted July 1, 2017 Share Posted July 1, 2017 Im trying to build a query using a variable. Unfortunately my piece of code is not working. Im basically rewriting this query: {{$topic_id = \IPS\Db::i()->select('topic_id', 'forums_posts', 'author_id="27"', NULL, 1)->first();}} Into this (where author id is a variable) {{$BuildQuery = \IPS\Db::i()->build(array('select' => 'topic_id', 'from' => 'forums_posts', 'where' => 'author_id=' . {$foundMemberId}, "", 'limit' => '1'));}} What am I doing wrong in my 'build' code? Link to comment Share on other sites More sharing options...
newbie LAC Posted July 2, 2017 Share Posted July 2, 2017 8 hours ago, microsoftdotcom said: {{$BuildQuery = \IPS\Db::i()->build There you found method build? I remember similar method in 3.X Link to comment Share on other sites More sharing options...
microsoftdotcom Posted July 3, 2017 Author Share Posted July 3, 2017 On 2-7-2017 at 8:37 AM, newbie LAC said: There you found method build? I remember similar method in 3.X I just blindly assume that the build method is inside the same location as the select method (since the select method works) But I might be wrong, thats why I'm asking for assistance Link to comment Share on other sites More sharing options...
newbie LAC Posted July 3, 2017 Share Posted July 3, 2017 What are you trying to get/do? If you need to pass a var in your first code {{$topic_id = \IPS\Db::i()->select('topic_id', 'forums_posts', array('author_id=?', $foundMemberId), NULL, 1)->first();}} first() method throw an exception so use try/catch Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.