Data at Your Fingertips: Explore Our New Reporting and Statistical Capabilities By Ryan Ashbrook Tuesday at 01:29 PM
IndianaJoe Posted September 25, 2017 Share Posted September 25, 2017 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? Link to comment Share on other sites More sharing options...
Daniel F Posted September 25, 2017 Share Posted September 25, 2017 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(); Link to comment Share on other sites More sharing options...
IndianaJoe Posted September 25, 2017 Author Share Posted September 25, 2017 Thanks, I got it to work. I tried that previously, but was having issues with the array function. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.