Dave_L Posted March 20, 2003 Share Posted March 20, 2003 Reading the queries within the code would be easier if a couple of changes were made: 1) Split the parts of the queries onto separate lines 2) Embed variables into the strings, rather than using the concatenation operator. Braces {} can be used for complex variables when needed. Example (current): $history_query_raw = "select o.orders_id, o.date_purchased, o.delivery_name, ot.text as order_total, s.orders_status_name from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id) left join " . TABLE_ORDERS_STATUS . " s on (o.orders_status = s.orders_status_id and s.language_id = '" . $languages_id . "') where o.customers_id = '" . $customer_id . "' and ot.class = 'ot_total' order by orders_id DESC"; Example (after revision): $history_query_raw = " select o.orders_id, o.date_purchased, o.delivery_name, ot.text as order_total, s.orders_status_name from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id) left join " . TABLE_ORDERS_STATUS . " s on (o.orders_status = s.orders_status_id and s.language_id = '$languages_id') where o.customers_id = '$customer_id' and ot.class = 'ot_total' order by orders_id DESC "; 3) It also might help if the table names were copied into variables: Example (after revision): $table_orders = TABLE_ORDERS; $table_orders_total = TABLE_ORDERS_TOTAL; $table_orders_status = TABLE_ORDERS_STATUS; $history_query_raw = " select o.orders_id, o.date_purchased, o.delivery_name, ot.text as order_total, s.orders_status_name from $table_orders as o left join $table_orders_total ot on (o.orders_id = ot.orders_id) left join $table_orders_status s on (o.orders_status = s.orders_status_id and s.language_id = '$languages_id') where o.customers_id = '$customer_id' and ot.class = 'ot_total' order by orders_id DESC "; What do you think? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.