ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilTermsOfServiceTableDatabaseDataProvider Class Reference
+ Inheritance diagram for ilTermsOfServiceTableDatabaseDataProvider:
+ Collaboration diagram for ilTermsOfServiceTableDatabaseDataProvider:

Public Member Functions

 __construct (ilDBInterface $db)
 ilTermsOfServiceTableDatabaseDataProvider constructor. More...
 
 getList (array $params, array $filter)
 

Protected Member Functions

 getSelectPart (array $params, array $filter)
 
 getFromPart (array $params, array $filter)
 
 getWherePart (array $params, array $filter)
 
 getGroupByPart (array $params, array $filter)
 
 getHavingPart (array $params, array $filter)
 
 getOrderByPart (array $params, array $filter)
 

Protected Attributes

 $db
 

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 11 of file class.ilTermsOfServiceTableDatabaseDataProvider.php.

Constructor & Destructor Documentation

◆ __construct()

ilTermsOfServiceTableDatabaseDataProvider::__construct ( ilDBInterface  $db)

Member Function Documentation

◆ getFromPart()

ilTermsOfServiceTableDatabaseDataProvider::getFromPart ( array  $params,
array  $filter 
)
abstractprotected
Parameters
array$params
array$filter
Returns
string

Referenced by __construct(), and getList().

+ Here is the caller graph for this function:

◆ getGroupByPart()

ilTermsOfServiceTableDatabaseDataProvider::getGroupByPart ( array  $params,
array  $filter 
)
abstractprotected
Parameters
array$params
array$filter
Returns
string

Referenced by __construct(), and getList().

+ Here is the caller graph for this function:

◆ getHavingPart()

ilTermsOfServiceTableDatabaseDataProvider::getHavingPart ( array  $params,
array  $filter 
)
abstractprotected
Parameters
array$params
array$filter
Returns
string

Referenced by __construct(), and getList().

+ Here is the caller graph for this function:

◆ getList()

ilTermsOfServiceTableDatabaseDataProvider::getList ( array  $params,
array  $filter 
)
Parameters
array$params
array$filter
Returns
array
Exceptions
InvalidArgumentException

Implements ilTermsOfServiceTableDataProvider.

Definition at line 81 of file class.ilTermsOfServiceTableDatabaseDataProvider.php.

References $data, $query, $res, $row, array, getFromPart(), getGroupByPart(), getHavingPart(), getOrderByPart(), getSelectPart(), and getWherePart().

82  {
83  $data = array(
84  'items' => array(),
85  'cnt' => 0
86  );
87 
88  $select = $this->getSelectPart($params, $filter);
89  $where = $this->getWherePart($params, $filter);
90  $from = $this->getFromPart($params, $filter);
91  $order = $this->getOrderByPart($params, $filter);
92  $group = $this->getGroupByPart($params, $filter);
93  $having = $this->getHavingPart($params, $filter);
94 
95  if(isset($params['limit']))
96  {
97  if(!is_numeric($params['limit']))
98  {
99  throw new InvalidArgumentException('Please provide a valid numerical limit.');
100  }
101 
102  if(!isset($params['offset']))
103  {
104  $params['offset'] = 0;
105  }
106  else if(!is_numeric($params['offset']))
107  {
108  throw new InvalidArgumentException('Please provide a valid numerical offset.');
109  }
110 
111  $this->db->setLimit($params['limit'], $params['offset']);
112  }
113 
114  $where = strlen($where) ? 'WHERE ' . $where : '';
115  $query = "SELECT {$select} FROM {$from} {$where}";
116 
117  if(strlen($group))
118  {
119  $query .= " GROUP BY {$group}";
120  }
121 
122  if(strlen($having))
123  {
124  $query .= " HAVING {$having}";
125  }
126 
127  if(strlen($order))
128  {
129  $query .= " ORDER BY {$order}";
130  }
131 
132  $res = $this->db->query($query);
133  while($row = $this->db->fetchAssoc($res))
134  {
135  $data['items'][] = $row;
136  }
137 
138  if(isset($params['limit']))
139  {
140  $cnt_sql = "SELECT COUNT(*) cnt FROM ({$query}) subquery";
141  $row_cnt = $this->db->fetchAssoc($this->db->query($cnt_sql));
142  $data['cnt'] = $row_cnt['cnt'];
143  }
144 
145  return $data;
146  }
getSelectPart(array $params, array $filter)
getOrderByPart(array $params, array $filter)
getGroupByPart(array $params, array $filter)
getHavingPart(array $params, array $filter)
getFromPart(array $params, array $filter)
getWherePart(array $params, array $filter)
Create styles array
The data for the language used.
$params
Definition: example_049.php:96
+ Here is the call graph for this function:

◆ getOrderByPart()

ilTermsOfServiceTableDatabaseDataProvider::getOrderByPart ( array  $params,
array  $filter 
)
abstractprotected
Parameters
array$params
array$filter
Returns
string

Referenced by __construct(), and getList().

+ Here is the caller graph for this function:

◆ getSelectPart()

ilTermsOfServiceTableDatabaseDataProvider::getSelectPart ( array  $params,
array  $filter 
)
abstractprotected
Parameters
array$params
array$filter
Returns
string

Referenced by __construct(), and getList().

+ Here is the caller graph for this function:

◆ getWherePart()

ilTermsOfServiceTableDatabaseDataProvider::getWherePart ( array  $params,
array  $filter 
)
abstractprotected
Parameters
array$params
array$filter
Returns
string

Referenced by __construct(), and getList().

+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilTermsOfServiceTableDatabaseDataProvider::$db
protected

Definition at line 16 of file class.ilTermsOfServiceTableDatabaseDataProvider.php.

Referenced by __construct().


The documentation for this class was generated from the following file: