3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $filters = []; $start = 0; $csv = true; $count = false; $full = true; $whereClause = " WHERE c.cID IS NOT NULL AND p.status NOT IN ('hidden')"; $orderBy = " ORDER BY "; $params = array(); if(is_null($filters)&& isset($_SESSION['claimfilters']) && !is_null($_SESSION['claimfilters']) && !$csv) $filters = unserialize($_SESSION['claimfilters']); if(!is_null($filters)) { if(isset($filters['pID']) && $filters['pID'] != "" && !is_null($filters['pID'])) { $whereClause .= " AND c.pID = :pID"; $params['pID'] = $filters['pID']; } if(isset($filters['cnID']) && $filters['cnID'] && !is_null($filters['cnID'])) { //$whereClause .= " AND p.cnID = :cnID"; $country = new Country($filters['cnID']); if($country->code=='gb'){$country->code='en';} $whereClause .= " AND con.lang IN ('" . $country->code ."')"; } if(isset($filters['ptID']) && $filters['ptID'] && !is_null($filters['ptID'])) { $whereClause .= " AND p.ptID = :ptID"; $params['ptID'] = $filters['ptID']; } if(isset($filters['customerType']) && $filters['customerType'] != "") { $whereClause .= " AND con.customerType = :customerType"; $params['customerType'] = $filters['customerType']; } if(isset($filters['status']) && $filters['status'] != "") { $whereClause .= " AND c.status = :status"; $params['status'] = $filters['status']; } if(isset($filters['slug']) && $filters['slug'] != "") { $whereClause .= " AND p.slug = :slug"; $params['slug'] = $filters['slug']; } if(isset($filters['redemptionstatus']) && $filters['redemptionstatus'] != "") { $whereClause .= " AND c.cID IN (SELECT DISTINCT(r.cID) FROM claims_redemptions r WHERE r.status = :redemptionstatus)"; $params['redemptionstatus'] = $filters['redemptionstatus']; } if(isset($filters['startDate']) && $filters['startDate'] != "" && isset($filters['endDate']) && $filters['endDate'] != "") { $whereClause .= " AND DATE(c.date_created) BETWEEN :startDate AND :endDate"; $params['startDate'] = $filters['startDate']; $params['endDate'] = $filters['endDate']; } if(isset($filters['sort']) && $filters['sort'] != "") { $orderBy = " e." . $filters['sort']." ".$filters['direction'] . ","; } if(isset($filters['search']) && $filters['search'] != "") { $whereClause .= " AND ( c.cID = '".$filters['search']."' OR con.email LIKE '%".$filters['search']."%' OR con.surname LIKE '%".$filters['search']."%' OR con.postcode LIKE '%".$filters['search']."%' )"; } if(isset($filters['actioneddate']) && $filters['actioneddate'] != "") { if(isset($filters['status']) && $filters['status'] != "") { switch($filters['status']) { case 'processed' : $date = 'date_processed'; break; case 'validated' : $date = 'date_validated'; break; case 'rejected' : $date = 'date_rejected'; break; } $whereClause .= " AND DATE(" . $date . ") = :actioned"; } else { $whereClause .= " AND (DATE(date_processed) = :actioned OR DATE(date_validated) = :actioned OR DATE(date_rejected) = :actioned)"; } $params['actioned'] = $filters['actioneddate']; } } $orderBy .= "c.cID ASC"; if(!$csv) $_SESSION['claimfilters'] = serialize($filters); $sql = "SELECT "; if($count) { $sql .= "COUNT(*)"; } elseif($full) { $sql .= "SQL_CALC_FOUND_ROWS r.*, r.cashback AS r_cashback, c.*, pr.*, con.*, pur.*, DATEDIFF(date_received,invoiceDate) as daysTaken, p.promoName, p.cnID, p.ptID, c.cID AS cID"; } else { $sql .= "SQL_CALC_FOUND_ROWS c.*, con.*, pur.*, DATEDIFF(date_received,invoiceDate) as daysTaken, p.promoName, p.cnID, p.ptID, p.paymentPeriod, c.cID AS cID, (SELECT SUM(cashback) FROM claims_redemptions WHERE cID = c.cID AND `status` NOT IN ('invalid','incomplete')) AS `cashback_amount`"; } if($full) { $sql .= " FROM claims_redemptions r LEFT JOIN claims c ON c.cID = r.cID LEFT JOIN consumers con ON c.conID = con.conID LEFT JOIN claims_purchases pur ON c.cID = pur.cID LEFT JOIN promotions p ON c.pID = p.pID LEFT JOIN promotions_products pr ON r.prID = pr.prID "; } else { $sql .= " FROM claims c LEFT JOIN consumers con ON c.conID = con.conID LEFT JOIN claims_purchases pur ON c.cID = pur.cID LEFT JOIN promotions p ON c.pID = p.pID "; } $sql .= $whereClause . $orderBy; $sql .= (!$csv) ? " LIMIT " . $start . ", " . $GLOBALS['config']->general->num_per_page : ""; die($sql); if(!$count) return DatabaseHandler::GetAll($sql,$params); else return DatabaseHandler::GetOne($sql,$params);
based on oZNDU
Output for 5.4.0 - 7.2.0
SELECT SQL_CALC_FOUND_ROWS r.*, r.cashback AS r_cashback, c.*, pr.*, con.*, pur.*, DATEDIFF(date_received,invoiceDate) as daysTaken, p.promoName, p.cnID, p.ptID, c.cID AS cID FROM claims_redemptions r LEFT JOIN claims c ON c.cID = r.cID LEFT JOIN consumers con ON c.conID = con.conID LEFT JOIN claims_purchases pur ON c.cID = pur.cID LEFT JOIN promotions p ON c.pID = p.pID LEFT JOIN promotions_products pr ON r.prID = pr.prID WHERE c.cID IS NOT NULL AND p.status NOT IN ('hidden') ORDER BY c.cID ASC
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/DPAZ5 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/DPAZ5 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/DPAZ5 on line 3
Process exited with code 255.