The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (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
DB.php patch - error handling, flexible WHERE clauses, fix bug
#14
I'm not sure what you mean because UserSpice already has functions
Code:
update()
,
Code:
insert()
, and
Code:
delete()
. See documentation.

It's not called ADD but INSERT and it doesn't have a WHERE clause. See SQL tutorial.

===

With this patch you can already use nested triads for
Code:
delete()
. For example:

Code:
$db->delete("Products", ["or", ["Stock","<=",0], ["Legal","=",false]]);

I've noticed that the query is still being run even if the argument was incorrect. This is also the case with the original DB.php. For example:
Code:
delete("Products",NULL)
is going to clear the table. To fix it I've added an error flag. Lines 86-91, 98, 159, 186 in my paste.

Passing empty array is now prohibited (line 195).

===

Statement UPDATE uses WHERE clause so I might as well implement triads. Lines 239-253 in my paste. Now you can do this:

Code:
$db->update("Suppliers", ["Country","=","Greece"], ["Currency"=>"GRD"]);
  Reply


Messages In This Thread
DB.php patch - error handling, flexible WHERE clauses, fix bug - by faguss - 06-18-2017, 12:29 PM

Forum Jump:


Users browsing this thread: 7 Guest(s)