From 4644dd2e4623786f961c308aad858bcf9f4c6a34 Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Sat, 15 Jun 2019 09:39:08 +0100 Subject: [PATCH] MySQL queries consistency check --- application/models/Attribute.php | 4 ++-- application/models/Item.php | 2 +- application/models/Module.php | 4 ++-- application/models/Sale.php | 4 ++-- application/models/reports/Detailed_receivings.php | 10 +++++----- application/models/reports/Inventory_summary.php | 4 ++-- application/models/reports/Specific_discount.php | 4 ++-- application/models/reports/Summary_discounts.php | 6 +++--- application/models/reports/Summary_payments.php | 4 ++-- application/models/reports/Summary_sales_taxes.php | 2 +- application/models/reports/Summary_taxes.php | 2 +- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/application/models/Attribute.php b/application/models/Attribute.php index f02f88be5..48a7fc402 100644 --- a/application/models/Attribute.php +++ b/application/models/Attribute.php @@ -336,7 +336,7 @@ class Attribute extends CI_Model $this->db->from('ospos_attribute_links'); $this->db->where('definition_id',$definition_id); - $this->db->where('item_id',NULL); + $this->db->where('item_id', NULL); $success = $this->db->delete(); $this->db->trans_complete(); @@ -371,7 +371,7 @@ class Attribute extends CI_Model { $this->db->select('definition_type, definition_name'); $this->db->from('attribute_definitions'); - $this->db->where('definition_id',$definition_id); + $this->db->where('definition_id', $definition_id); $row = $this->db->get()->row(); $from_definition_type = $row->definition_type; diff --git a/application/models/Item.php b/application/models/Item.php index 9b7cc7780..5bac47d7f 100644 --- a/application/models/Item.php +++ b/application/models/Item.php @@ -329,7 +329,7 @@ class Item extends CI_Model if(!$include_deleted) { - $this->db->where("items.deleted = '0'"); + $this->db->where('items.deleted', 0); } // limit to only 1 so there is a result in case two are returned diff --git a/application/models/Module.php b/application/models/Module.php index 3937586f8..c4a916863 100644 --- a/application/models/Module.php +++ b/application/models/Module.php @@ -49,9 +49,9 @@ class Module extends CI_Model public function get_all_subpermissions() { $this->db->from('permissions'); - $this->db->join('modules', 'modules.module_id = permissions.module_id'); + $this->db->join('modules AS modules', 'modules.module_id = permissions.module_id'); // can't quote the parameters correctly when using different operators.. - $this->db->where($this->db->dbprefix('modules') . '.module_id!=', 'permission_id', FALSE); + $this->db->where('modules.module_id != ', 'permission_id', FALSE); return $this->db->get(); } diff --git a/application/models/Sale.php b/application/models/Sale.php index b95df7a41..1c96627ce 100644 --- a/application/models/Sale.php +++ b/application/models/Sale.php @@ -1363,7 +1363,7 @@ class Sale extends CI_Model 'status' => 0 ); - $this->db->where('dinner_table_id',$dinner_table); + $this->db->where('dinner_table_id', $dinner_table); $this->db->update('dinner_tables', $dinner_table_data); $this->update_sale_status($sale_id, CANCELED); @@ -1386,7 +1386,7 @@ class Sale extends CI_Model 'status' => 0 ); - $this->db->where('dinner_table_id',$dinner_table); + $this->db->where('dinner_table_id', $dinner_table); $this->db->update('dinner_tables', $dinner_table_data); $this->db->delete('sales_payments', array('sale_id' => $sale_id)); diff --git a/application/models/reports/Detailed_receivings.php b/application/models/reports/Detailed_receivings.php index c2f3f795b..13d3be8f4 100644 --- a/application/models/reports/Detailed_receivings.php +++ b/application/models/reports/Detailed_receivings.php @@ -78,11 +78,11 @@ class Detailed_receivings extends Report if($inputs['receiving_type'] == 'receiving') { - $this->db->where('quantity_purchased > 0'); + $this->db->where('quantity_purchased >', 0); } elseif($inputs['receiving_type'] == 'returns') { - $this->db->where('quantity_purchased < 0'); + $this->db->where('quantity_purchased <', 0); } elseif($inputs['receiving_type'] == 'requisitions') { @@ -126,15 +126,15 @@ class Detailed_receivings extends Report if($inputs['receiving_type'] == 'receiving') { - $this->db->where('quantity_purchased > 0'); + $this->db->where('quantity_purchased >', 0); } elseif($inputs['receiving_type'] == 'returns') { - $this->db->where('quantity_purchased < 0'); + $this->db->where('quantity_purchased <', 0); } elseif($inputs['receiving_type'] == 'requisitions') { - $this->db->where('quantity_purchased = 0'); + $this->db->where('quantity_purchased', 0); } return $this->db->get()->row_array(); diff --git a/application/models/reports/Inventory_summary.php b/application/models/reports/Inventory_summary.php index 37736df9d..2a88c6074 100644 --- a/application/models/reports/Inventory_summary.php +++ b/application/models/reports/Inventory_summary.php @@ -30,11 +30,11 @@ class Inventory_summary extends Report // should be corresponding to values Inventory_summary::getItemCountDropdownArray() returns... if($inputs['item_count'] == 'zero_and_less') { - $this->db->where('item_quantities.quantity <= 0'); + $this->db->where('item_quantities.quantity <=', 0); } elseif($inputs['item_count'] == 'more_than_zero') { - $this->db->where('item_quantities.quantity > 0'); + $this->db->where('item_quantities.quantity >', 0); } if($inputs['location_id'] != 'all') diff --git a/application/models/reports/Specific_discount.php b/application/models/reports/Specific_discount.php index 03f05623d..988092068 100755 --- a/application/models/reports/Specific_discount.php +++ b/application/models/reports/Specific_discount.php @@ -72,7 +72,7 @@ class Specific_discount extends Report $this->db->from('sales_items_temp'); $this->db->where('discount >=', $inputs['discount']); - $this->db->where('discount_type',$inputs['discount_type']); + $this->db->where('discount_type', $inputs['discount_type']); if($inputs['sale_type'] == 'complete') { @@ -140,7 +140,7 @@ class Specific_discount extends Report $this->db->from('sales_items_temp'); $this->db->where('discount >=', $inputs['discount']); - $this->db->where('discount_type',$inputs['discount_type']); + $this->db->where('discount_type', $inputs['discount_type']); if($inputs['sale_type'] == 'complete') { diff --git a/application/models/reports/Summary_discounts.php b/application/models/reports/Summary_discounts.php index 02b3970ff..925165740 100644 --- a/application/models/reports/Summary_discounts.php +++ b/application/models/reports/Summary_discounts.php @@ -17,15 +17,15 @@ class Summary_discounts extends Summary_report if($inputs['discount_type'] == FIXED) { $this->db->select('SUM(sales_items.discount) AS total, MAX(CONCAT("'.$this->config->item('currency_symbol').'",sales_items.discount)) AS discount, count(*) AS count'); - $this->db->where('discount_type',FIXED); + $this->db->where('discount_type', FIXED); } elseif($inputs['discount_type'] == PERCENT) { $this->db->select('SUM(item_unit_price) * sales_items.discount / 100.0 AS total, MAX(CONCAT(sales_items.discount, "%")) AS discount, count(*) AS count'); - $this->db->where('discount_type',PERCENT); + $this->db->where('discount_type', PERCENT); } - $this->db->where('discount > 0'); + $this->db->where('discount >', 0); $this->db->group_by('sales_items.discount'); $this->db->order_by('sales_items.discount'); diff --git a/application/models/reports/Summary_payments.php b/application/models/reports/Summary_payments.php index c1ed92f68..cc5adc85f 100644 --- a/application/models/reports/Summary_payments.php +++ b/application/models/reports/Summary_payments.php @@ -58,7 +58,7 @@ class Summary_payments extends Summary_report $this->db->from('ospos_sales AS sales'); $this->db->join('sumpay_items_temp AS sumpay_items', 'sales.sale_id = sumpay_items.sale_id', 'left outer'); $this->db->join('sumpay_payments_temp AS sumpay_payments', 'sales.sale_id = sumpay_payments.sale_id', 'left outer'); - $this->db->where('sales.sale_status = ' . COMPLETED); + $this->db->where('sales.sale_status', COMPLETED); $this->_where($inputs); $this->db->group_by("trans_type"); @@ -86,7 +86,7 @@ class Summary_payments extends Summary_report $this->db->select($select); $this->db->from('sales AS sales'); $this->db->join('sales_payments AS sales_payments', 'sales.sale_id = sales_payments.sale_id', 'left outer'); - $this->db->where('sales.sale_status = ' . COMPLETED); + $this->db->where('sales.sale_status', COMPLETED); $this->_where($inputs); $this->db->group_by("sales_payments.payment_type"); diff --git a/application/models/reports/Summary_sales_taxes.php b/application/models/reports/Summary_sales_taxes.php index f8d68b9a8..1a64a4627 100644 --- a/application/models/reports/Summary_sales_taxes.php +++ b/application/models/reports/Summary_sales_taxes.php @@ -16,7 +16,7 @@ class Summary_sales_taxes extends Summary_report protected function _where(array $inputs) { - $this->db->where('sales.sale_status = ' . COMPLETED); + $this->db->where('sales.sale_status', COMPLETED); if(empty($this->config->item('date_or_time_format'))) { diff --git a/application/models/reports/Summary_taxes.php b/application/models/reports/Summary_taxes.php index 2c21140e0..9ae838306 100644 --- a/application/models/reports/Summary_taxes.php +++ b/application/models/reports/Summary_taxes.php @@ -16,7 +16,7 @@ class Summary_taxes extends Summary_report protected function _where(array $inputs) { - $this->db->where('sales.sale_status = ' . COMPLETED); + $this->db->where('sales.sale_status', COMPLETED); if(empty($this->config->item('date_or_time_format'))) {