34 abstract protected function getFromPart(array $params, array $filter) : string;
41 abstract protected function getWherePart(array $params, array $filter) : string;
48 abstract protected function getGroupByPart(array $params, array $filter) : string;
56 abstract protected function getHavingPart(array $params, array $filter) : string;
63 abstract protected function getOrderByPart(array $params, array $filter) : string;
71 public function getList(array $params, array $filter) : array
85 if (isset($params[
'limit'])) {
86 if (!is_numeric($params[
'limit'])) {
87 throw new \InvalidArgumentException(
'Please provide a valid numerical limit.');
90 if (!isset($params[
'offset'])) {
91 $params[
'offset'] = 0;
93 if (!is_numeric($params[
'offset'])) {
94 throw new \InvalidArgumentException(
'Please provide a valid numerical offset.');
98 $this->db->setLimit($params[
'limit'], $params[
'offset']);
101 $where = strlen($where) ?
'WHERE ' . $where :
'';
102 $query =
"SELECT {$select} FROM {$from} {$where}";
104 if (strlen($group)) {
105 $query .=
" GROUP BY {$group}";
108 if (strlen($having)) {
109 $query .=
" HAVING {$having}";
112 if (strlen($order)) {
113 $query .=
" ORDER BY {$order}";
117 while (
$row = $this->db->fetchAssoc(
$res)) {
121 if (isset($params[
'limit'])) {
122 $cnt_sql =
"SELECT COUNT(*) cnt FROM ({$query}) subquery";
123 $row_cnt = $this->db->fetchAssoc($this->db->query($cnt_sql));
124 $data[
'cnt'] = $row_cnt[
'cnt'];
getSelectPart(array $params, array $filter)
getOrderByPart(array $params, array $filter)
getList(array $params, array $filter)
getGroupByPart(array $params, array $filter)
getHavingPart(array $params, array $filter)
Interface ilTermsOfServiceTableDataProvider.
__construct(\ilDBInterface $db)
ilTermsOfServiceTableDatabaseDataProvider constructor.
getFromPart(array $params, array $filter)
foreach($_POST as $key=> $value) $res
getWherePart(array $params, array $filter)
Class ilTermsOfServiceTableDatabaseDataProvider.