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
Retrieving details from a Database to table
#14
Code:
$customerQ  = $db->query("SELECT * FROM customers")
Code:
$customers = $customerQ->results();

This doesn't make sense to me because $customerQ is not a copy of the object. Just use $db variable and check for error first. Otherwise $customers are going to be results from the previous query.

Code:
if (!$db->query("SELECT * FROM customers")->error())
Code:
$customers = $db->results();

In my version results are always cleared.

====

Also I'll hijack this thread to mention inconsistent return values. It's kinda weird to me that you can do this:

Code:
$array = $db->query(...)->results();

but not this:

Code:
$array = $db->get(...)->results();

I actually made a modification where it would always return object. However, I reverted it because there was no benefit for me. My queries have gotten complicated and I just use query() for getting data and rarely other functions.

EDIT: On the other hand returning bool forces you to check error which is a good practice.
  Reply


Messages In This Thread
Retrieving details from a Database to table - by faguss - 07-11-2017, 03:14 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)