Jump to content

Building query doesnt work

Featured Replies

Posted

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? 

8 hours ago, microsoftdotcom said:

{{$BuildQuery = \IPS\Db::i()->build

There you found method build? I remember similar method in 3.X

  • Author
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 :)

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

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.