Jump to content

Building query doesnt work


Recommended Posts

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? 

Posted
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 :)

Posted

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 members

    • No registered users viewing this page.
×
×
  • Create New...