File: /home/mostafedeg/public_html/erp/models/mysql/ext/RestaurantorderdetailsMySqlExtDAO.class.php
<?php
/**
* Class that operate on table 'restaurantorderdetails'. Database Mysql.
*
* @author: http://phpdao.com
* @date: 2018-05-16 11:38
*/
class RestaurantorderdetailsMySqlExtDAO extends RestaurantorderdetailsMySqlDAO {
public function getlastrestaurantorderdetails($orderId) {
$sql = 'SELECT * FROM `restaurantorderdetails`
left join product on restaurantorderdetails.productId = product.productId
left join productcat on product.productCatId = productcat.productCatId
WHERE orderId = '.$orderId;
$sqlQuery = new SqlQuery($sql);
return $this->getList($sqlQuery);
}
public function queryByOrderIdAndProduct($orderid, $productId) {
$sql = 'SELECT * FROM restaurantorderdetails WHERE productId = ' . $productId . ' and orderId = ' . $orderid;
$sqlQuery = new SqlQuery($sql);
return $this->getList($sqlQuery);
}
public function deleteByOrderIdAndProduct($orderid, $productId) {
$sql = 'DELETE FROM restaurantorderdetails WHERE productId = ' . $productId . ' and orderId = ' . $orderid;
$sqlQuery = new SqlQuery($sql);
return $this->executeUpdate($sqlQuery);
}
public function changeorderid($orderId, $id) {
$sql = 'UPDATE restaurantorderdetails SET orderId = "' . $orderId . '" WHERE id = ' . $id;
$sqlQuery = new SqlQuery($sql);
return $this->executeUpdate($sqlQuery);
}
public function queryByOrderIdEX($value) {
$sql = 'SELECT restaurantorderdetails.*,product.productName
FROM restaurantorderdetails
join product on product.productId = restaurantorderdetails.productId
WHERE orderId = ?';
$sqlQuery = new SqlQuery($sql);
$sqlQuery->setNumber($value);
return $this->getList($sqlQuery);
}
public function queryByOrderIdAndProductEX($orderId, $productId) {
$sql = 'SELECT *
FROM restaurantorderdetails
WHERE orderId = ' . $orderId . ' and productId = ' . $productId . '';
$sqlQuery = new SqlQuery($sql);
return $this->getRow($sqlQuery);
}
public function queryByOrderIdNotPrinted($value) {
$sql = 'SELECT restaurantorderdetails.*
FROM restaurantorderdetails
WHERE orderId = ? and isPrinted = 0';
$sqlQuery = new SqlQuery($sql);
$sqlQuery->setNumber($value);
return $this->getList($sqlQuery);
}
public function queryByOrderId($orderid) {
$sql = 'SELECT * FROM restaurantorderdetails WHERE orderId = ' . $orderid;
$sqlQuery = new SqlQuery($sql);
return $this->getList($sqlQuery);
}
public function getOrderDetailsTotal($orderid) {
$sql = 'SELECT sum(total)
FROM restaurantorderdetails
WHERE orderId = ' . $orderid;
$sqlQuery = new SqlQuery($sql);
return $this->querySingleResult($sqlQuery);
}
}
?>