Public Member Functions | |
ilElementList () | |
checkDb ($function) | |
check whether database handle and table are set dies if the database handle or the database table aren't set | |
setDbTable ($dbTable) | |
set database table | |
getDbTable () | |
get name of database table | |
setDbHandle ($dbHandle) | |
set database handle | |
getDbHandle () | |
get database handle | |
setIdField ($idField) | |
set unique database field | |
setWhereCond ($where) | |
set where condition for result fields | |
setOrderField ($orderField) | |
set database field for sorting results | |
setOrderDirection ($orderDirection) | |
set sorting direction for results: ASC or DESC | |
selectDbAll () | |
select all datasets of one database table without any limitations | |
selectDbAllLimited ($start=0, $count=30) | |
select a limited number of datasets of one database table | |
selectDbAllByQuery ($query) | |
select datasets by query | |
getDbNextElement ($result="default") | |
get next dataset of a (optionally) given select result | |
countDb ($where="") | |
number of found datasets for a count query | |
countDbByQuery ($query) | |
number of found datasets for a count query | |
Data Fields | |
$dbHandle | |
$result | |
$dbTable | |
$idField = "id" | |
$orderField = "id" | |
$orderDirection = "ASC" | |
$whereCond = "1" | |
$element |
Definition at line 15 of file class.ilElementList.php.
ilElementList::checkDb | ( | $ | function | ) |
check whether database handle and table are set dies if the database handle or the database table aren't set
string | $function name of function that called this function private |
Definition at line 96 of file class.ilElementList.php.
Referenced by countDb(), selectDbAll(), and selectDbAllLimited().
{ if ($this->dbHandle == "") { die($function . ": No database handle given."); } if ($this->dbTable == "") { die($function . ": No database table given."); } }
ilElementList::countDb | ( | $ | where = "" |
) |
number of found datasets for a count query
string | $where limiting where statement |
Definition at line 303 of file class.ilElementList.php.
References $data, $q, $result, checkDb(), and getDbTable().
{ $this->checkDb("Liste::countDb()"); $q = "SELECT COUNT(*) FROM " . $this->getDbTable(); if ($where != "") { $q .= " WHERE " . $where; } else { $q .= " WHERE (" . $this->whereCond . ")"; } $result = $this->dbHandle->query($q); if (DB::isError($result)) { die("Liste::countDb(): ".$result->getMessage()); } if (is_array($data = $result->fetchRow())) { return $data[0]; } else { return 0; } } //end function countDb
ilElementList::countDbByQuery | ( | $ | query | ) |
number of found datasets for a count query
string | $query count query (e.g. SELECT COUNT(*) FROM TABLE) |
Definition at line 330 of file class.ilElementList.php.
References $data, $query, and $result.
{ if ($this->dbHandle == "") { die("Liste::countDbByQuery(): No database handle given."); } if ($query == "") { die("Liste::countDbByQuery(): No query given."); } $result = $this->dbHandle->query($query); if (DB::isError($result)) { die("Liste::countDbByQuery(): ".$result->getMessage()); } if (is_array($data = $result->fetchRow())) { return $data[0]; } else { return 0; } } //end function countDbByQuery
ilElementList::getDbHandle | ( | ) |
get database handle
Definition at line 149 of file class.ilElementList.php.
{
return $this->dbHandle;
}
ilElementList::getDbNextElement | ( | $ | result = "default" |
) |
get next dataset of a (optionally) given select result
string | result identifier returned by functions like selectDbAll(), selectDbAllLimited(), selectDbAllByQuery() |
Definition at line 278 of file class.ilElementList.php.
References $data, and $result.
{ //check result if ($result=="default") { $result=$this->result; } if (!is_object($result)) { die("Liste::getDbNextElement(): No result object given."); } //get the next dataset if (is_array($data = $result->fetchRow(DB_FETCHMODE_ASSOC))) { $this->element->setData($data); return true; } else { return false; } }
ilElementList::getDbTable | ( | ) |
get name of database table
Definition at line 125 of file class.ilElementList.php.
Referenced by countDb(), selectDbAll(), and selectDbAllLimited().
{
return $this->dbTable;
}
ilElementList::ilElementList | ( | ) |
Definition at line 80 of file class.ilElementList.php.
{ $this->idField="id"; $this->orderField="id"; $this->orderDirection="ASC"; $this->whereCond="1"; $this->element = new ilElement(); }
ilElementList::selectDbAll | ( | ) |
select all datasets of one database table without any limitations
Definition at line 217 of file class.ilElementList.php.
References $result, checkDb(), and getDbTable().
{ $this->checkDb("Liste::selectDbAll()"); # echo "SELECT * FROM " . $this->getDbTable() . " WHERE (".$this->whereCond.") ORDER BY " . $this->orderField . " " . $this->orderDirection; $result = $this->dbHandle->query("SELECT * FROM " . $this->getDbTable() . " WHERE (".$this->whereCond.") ORDER BY " . $this->orderField . " " . $this->orderDirection); if (DB::isError($result)) { die("Liste::selectDbAll(): ".$result->getMessage()); } $this->result=$result; return $result; }
ilElementList::selectDbAllByQuery | ( | $ | query | ) |
select datasets by query
string | $query select statement |
Definition at line 255 of file class.ilElementList.php.
References $query, and $result.
{ if ($this->dbHandle == "") { die("Liste::selectDbAllByQuery(): No database handle given."); } if ($query == "") { die("Liste::selectDbAllByQuery(): No query given."); } $result = $this->dbHandle->query($query); if (DB::isError($result)) { die("Liste::selectDbAllByQuery(): ".$result->getMessage()); } $this->result=$result; return $result; }
ilElementList::selectDbAllLimited | ( | $ | start = 0 , |
|
$ | count = 30 | |||
) |
select a limited number of datasets of one database table
integer | $start first datasets to be selected | |
integer | $count max. number of datasets to be selected |
Definition at line 238 of file class.ilElementList.php.
References $result, checkDb(), and getDbTable().
{ $this->checkDb("Liste::selectDbQuery()"); $result = $this->dbHandle->query("SELECT * FROM " . $this->getDbTable() . " WHERE (".$this->whereCond.") ORDER BY " . $this->orderField . " " . $this->orderDirection . " LIMIT " . $start . ", " . $count); if (DB::isError($result)) { die("Liste::selectDbAllLimited(): ".$result->getMessage()); } $this->result=$result; return $result; }
ilElementList::setDbHandle | ( | $ | dbHandle | ) |
ilElementList::setDbTable | ( | $ | dbTable | ) |
ilElementList::setIdField | ( | $ | idField | ) |
ilElementList::setOrderDirection | ( | $ | orderDirection | ) |
set sorting direction for results: ASC or DESC
string | $orderDirection sorting direction |
Definition at line 203 of file class.ilElementList.php.
References $orderDirection.
{ if (($orderDirection != "ASC") && ($orderDirection != "DESC")) { return false; } else { $this->orderDirection = $orderDirection; } }
ilElementList::setOrderField | ( | $ | orderField | ) |
set database field for sorting results
string | $orderField database field for sorting |
Definition at line 188 of file class.ilElementList.php.
References $orderField.
{ if ($orderField == "") { die ("Liste::setOrderField(): No order field given."); } else { $this->orderField = $orderField; } }
ilElementList::setWhereCond | ( | $ | where | ) |
set where condition for result fields
string | $where condition for result fields |
Definition at line 173 of file class.ilElementList.php.
{ if ($where == "") { die ("Liste::setWhereCond(): No where condition given."); } else { $this->whereCond = $where; } }
ilElementList::$dbHandle |
Definition at line 23 of file class.ilElementList.php.
Referenced by setDbHandle().
ilElementList::$dbTable |
Definition at line 38 of file class.ilElementList.php.
Referenced by setDbTable().
ilElementList::$element |
Definition at line 78 of file class.ilElementList.php.
ilElementList::$idField = "id" |
Definition at line 46 of file class.ilElementList.php.
Referenced by setIdField().
ilElementList::$orderDirection = "ASC" |
Definition at line 62 of file class.ilElementList.php.
Referenced by setOrderDirection().
ilElementList::$orderField = "id" |
Definition at line 54 of file class.ilElementList.php.
Referenced by setOrderField().
ilElementList::$result |
Definition at line 30 of file class.ilElementList.php.
Referenced by countDb(), countDbByQuery(), getDbNextElement(), selectDbAll(), selectDbAllByQuery(), and selectDbAllLimited().
ilElementList::$whereCond = "1" |
Definition at line 70 of file class.ilElementList.php.