prepare($sql); //Bind to query if (str_contains($whereclause, ':condition')){ $stmt->bindValue('condition', $condition, PDO::PARAM_STR); } if (!empty($criterias)){ foreach ($criterias as $key => $value){ $key_condition = ':'.$key; if (str_contains($whereclause, $key_condition)){ if ($key == 'search'){ $search_value = '%'.$value.'%'; $stmt->bindValue($key, $search_value, PDO::PARAM_STR); } else { $stmt->bindValue($key, $value, PDO::PARAM_STR); } } } } //------------------------------------------ // Debuglog //------------------------------------------ if (debug){ $message = $date.';'.$sql.';'.$username; debuglog($message); } //Add paging details if(isset($criterias['totals']) && $criterias['totals']==''){ $stmt->execute(); $messages = $stmt->fetch(); $messages = $messages[0]; } elseif ((isset($criterias['list']) && $criterias['list']!='') || (isset($criterias['download']) && $criterias['download'] =='')){ //Excute Query $stmt->execute(); //Get results $messages = $stmt->fetchAll(PDO::FETCH_ASSOC); } else { $current_page = isset($criterias['p']) && is_numeric($criterias['p']) ? (int)$criterias['p'] : 1; $stmt->bindValue('page', ($current_page - 1) * $page_rows_cartest, PDO::PARAM_INT); $stmt->bindValue('num_products', $page_rows_cartest, PDO::PARAM_INT); //Excute Query $stmt->execute(); //Get results $messages = $stmt->fetchAll(PDO::FETCH_ASSOC); } //Encrypt results $messages = generate_payload($messages); //Send results echo $messages; ?>