The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug in db query->count?
#9
Yep. You're correct. That's one of the weird things about using the singleton method of db connection. If you establish a new connection to the db (name/pw/etc) every time you make a query/page, bad programming can cause you to make too many connections to the db. The way we call db::getInstance in the header, you will always have a single connection, no more, no less.

So that means, that your previous query is still in memory if there is one and if it fails, it may deliver results from that query.

Either way, best practice (using our method, mysqli, or just PDO in general), you want to properly bind your variables in an array to make absolutely SURE that the db is only searching that particular column for your info (and that someone isn't using a form to get up to mischief in your database). Note that if you are not getting outside information (ie variables) you can just pass the info in as normal ("SELECT * FROM users where id=1") works as you would expect.

I need to update the documentation. Especially the db documentation. I wrote that stuff when I barely understood the classes myself.
  Reply


Messages In This Thread
Bug in db query->count? - by Trioxin - 12-10-2016, 03:31 PM
Bug in db query->count? - by Trioxin - 12-10-2016, 03:56 PM
Bug in db query->count? - by Trioxin - 12-10-2016, 04:02 PM
Bug in db query->count? - by dan - 12-10-2016, 04:26 PM
Bug in db query->count? - by Trioxin - 12-10-2016, 04:40 PM
Bug in db query->count? - by dan - 12-10-2016, 05:00 PM
Bug in db query->count? - by Trioxin - 12-12-2016, 12:36 AM
Bug in db query->count? - by Trioxin - 12-12-2016, 03:20 AM
Bug in db query->count? - by mudmin - 12-12-2016, 04:18 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)