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
#11
Found incompatibility - passing empty array will make ERROR: w=Array ( ) appear on the screen. Fix:

Code:
if ($wcount==0) return "";

That's line 112 in my paste.
  Reply
#12
I wanted to use LIKE for comparing floats so I added it to the
Code:
$valid_ops
array. Also I implemented a bunch of other operators that might be useful in the future.

Lines 102-110, 131-155, 293-299 in my paste.

Examples: https://pastebin.com/mWvUsNAh
  Reply
#13
nice faguss, can you make all the function for all ??? like UPDATE ADD DELETE and other ?
  Reply
#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
#15
@faguss
Do you have the latest version of your db class? I'll shoot you an email.
  Reply


Forum Jump:


Users browsing this thread: 9 Guest(s)