Jump to content

Query Return 1 Result


IndianaJoe

Recommended Posts

Posted

I can't for the life of me fine the way to return 1 result for a query.

Right now I'm using

 \IPS\Db::i()->query("blah blah blah")

Then a foreach, which will only run once.

Is there a more efficient way of doing this?

Posted

If you expect only 1 result (e.g. from where id = x or count(*) queries) you can use the first() method.

\IPS\Db::i()->select( 'COUNT(*)', 'cms_database_categories' )->first();

 

Archived

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

  • Recently Browsing   0 members

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