I need to fetch the database records for particular date using database query , i tried some queries to fetch but it showing all records in table .
controller.php
public static function load($entry = array()){
$maxDate = \Drupal::request()->query->get('set_start_date');
$minDate = \Drupal::request()->query->get('set_end_date');
$select = db_select('pastpayments', 'x');
$select->fields('x');
foreach ($entry as $field => $value) {
$select->condition('paiddate', $maxDate, "<=");
$select->condition('paiddate', $minDate, ">=");
}
return $select->execute()->fetchAll();
}
public function entryList() {
$content = array();
$content['message'] = array(
'#markup' => $this->t('Generate a list of all entries in the database. There is no filter in the query.'),
);
$rows = array();
$headers = array(t('Member Id'), t('Name'), t('Paid Date'), t('Paid Date'));
foreach ($entries = $this->load() as $entry) {
// Sanitize each entry.
$rows[] = array_map('Drupal\Component\Utility\SafeMarkup::checkPlain', (array) $entry);
}
$content['table'] = array(
'#type' => 'table',
'#header' => $headers,
'#rows' => $rows,
'#empty' => t('No entries available.'),
);
// Don't cache this page.
$content['#cache']['max-age'] = 0;
return $content;
how i can fetch the table records for particular date ranges
database query
mysql> select * from pastpayments where paiddate >='2017/03/01' and paiddate <='2017/03/30';