Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #DB.php https://pastebin.com/Jp2EbDTw
- #Forum https://userspice.com/forums/topic/db-php-patch-error-handling-flexible-where-clauses-fix-bug/
- #example 1 https://pastebin.com/XmJR0Jk5
- #I've used examples from https://www.w3schools.com/sql/sql_between.asp as a benchmark
- #SQL https://pastebin.com/RKe1qHQT
- //SELECT * FROM Customers WHERE CustomerName LIKE 'a%'
- $result = $db -> get("Customers", ["CustomerName","LIKE","a%"]);
- //SELECT * FROM Persons WHERE Address IS NULL
- $result = $db -> get("Persons", ["Address","IS NULL"]);
- //SELECT * FROM Persons WHERE Address IS NOT NULL
- $result = $db -> get("Persons", ["Address","IS NOT NULL"]);
- //SELECT * FROM Products WHERE Price BETWEEN 10 AND 20
- $result = $db -> get("Products", ["Price","BETWEEN",10,20]);
- //SELECT * FROM Customers WHERE Country IN ('Germany', 'France', 'UK');
- $result = $db -> get("Customers", ["Country","IN",["Germany","France","UK"]]);
- //SELECT * FROM Customers WHERE Country IN (SELECT Country FROM Suppliers)
- $result = $db -> get("Customers", ["Country", "IN SELECT", "Suppliers", "Country"]);
- //SELECT * FROM Products WHERE (Price BETWEEN 10 AND 20) AND NOT CategoryID IN (2,3,4)
- $result = $db -> get("Products", [ "AND", ["Price","BETWEEN",10,20], ["NOT CategoryID","IN",[2,3,4]] ]);
- $result = $db -> get("Products", [ "AND NOT", ["Price","BETWEEN",10,20], [ "CategoryID","IN",[2,3,4]] ]);
- //SELECT * FROM Products WHERE ProductID = ANY (SELECT ProductID FROM OrderDetails WHERE Quantity >= 10)
- $result = $db -> get("Products", [ "ProductID", "=", "ANY", "OrderDetails", "ProductID", ["Quantity",">=","10"] ]);
- //SELECT * FROM Products WHERE ProductID = ALL (SELECT ProductID FROM OrderDetails WHERE Quantity = 10)
- $result = $db -> get("Products", [ "ProductID", "=", "ALL", "OrderDetails", "ProductID", ["Quantity", "=","10"] ]);
- //SELECT * FROM Suppliers WHERE EXISTS (SELECT ProductName FROM Products WHERE SupplierId = Suppliers.supplierId AND Price < 20)
- $result = $db -> get("Suppliers", [ "EXISTS", "Products", "ProductName", ["SupplierId=Suppliers.supplierId AND Price","<",20] ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement