The next step, we will try to optimize the QueryBuilder in order to get data based on TWO criteria in WHERE clause.
Again, we will use demo2026 project to implement it.
-
Create a new Custom File from Database Pane, by simply right-click on Custom Files, and choose Add File,
-
Enter the following info:
- File name: getquantityorderdetails.php
- Caption: Get Quantity of Order Details
- Include common files: enabled
- Path: (leave it blank)
-
Click on Code (Server Events, Client Scripts and Custom Templates) tab, and then click on Content under Custom Templates → Table-Specific → Custom Files, and put the following code::
<?php use Doctrine\DBAL\Types\Types; $orderID = 11077; $productID = 41; $qb = QueryBuilder(); $qb->select('Quantity') ->from('orderdetails') ->where('OrderID = :order_id') ->andWhere('ProductID = :product_id') ->setParameter('order_id', $orderID, Types::INTEGER) ->setParameter('product_id', $productID, Types::INTEGER) ->setMaxResults(1); $quantity = $qb->executeQuery()->fetchOne(); // Safe, returns first column of first row echo "Quantity of OrderID " . $orderID . " and ProductID " . $productID . " is: " . $quantity; ?> -
Re-generate ALL the script files,
-
Access the generated page from
http://localhost/demo2026/getquantityorderdetails(login by using username admin and password master).