Public Member Functions | Data Fields

ilElementList Class Reference

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

Detailed Description

Definition at line 15 of file class.ilElementList.php.


Member Function Documentation

ilElementList::checkDb ( function  ) 

check whether database handle and table are set dies if the database handle or the database table aren't set

Parameters:
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.");
        }
    }

Here is the caller graph for this function:

ilElementList::countDb ( where = ""  ) 

number of found datasets for a count query

Parameters:
string $where limiting where statement
Returns:
int number of found datasets public
See also:
countDbByQuery()

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

Here is the call graph for this function:

ilElementList::countDbByQuery ( query  ) 

number of found datasets for a count query

Parameters:
string $query count query (e.g. SELECT COUNT(*) FROM TABLE)
Returns:
int number of found datasets public
See also:
countDb()

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

Returns:
object database handle
See also:
$dbHandle Public

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

Parameters:
string result identifier returned by functions like selectDbAll(), selectDbAllLimited(), selectDbAllByQuery()
Returns:
boolean false if no further result datasets are given, otherwise true public
See also:
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

Returns:
string name of database table
See also:
$dbTable Public

Definition at line 125 of file class.ilElementList.php.

Referenced by countDb(), selectDbAll(), and selectDbAllLimited().

                          {
        return $this->dbTable;
    }

Here is the caller graph for this function:

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

Returns:
object result result identifier for use with getDbNextElement() public
See also:
checkDb(), selectDbAllLimited(), getDbNextElement()

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;
    }

Here is the call graph for this function:

ilElementList::selectDbAllByQuery ( query  ) 

select datasets by query

Parameters:
string $query select statement
Returns:
object result identifier for use with getDbNextElement() public

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

Parameters:
integer $start first datasets to be selected
integer $count max. number of datasets to be selected
Returns:
object database result identifier for use with getDbNextElement() public
See also:
selectDbAll(), getDbNextElement()

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;
    }

Here is the call graph for this function:

ilElementList::setDbHandle ( dbHandle  ) 

set database handle

Parameters:
string $dbHandle database handle
See also:
$dbHandle Public

Definition at line 135 of file class.ilElementList.php.

References $dbHandle.

                                    {
        if ($dbHandle == "") {
            die("Liste::setDbHandle(): No database handle given.");
        } else {
            $this->dbHandle = $dbHandle;
        }
    }

ilElementList::setDbTable ( dbTable  ) 

set database table

Parameters:
string $dbTable database table
See also:
$dbTable Public

Definition at line 111 of file class.ilElementList.php.

References $dbTable.

                                  {
        if ($dbTable == "") {
            die ("List::setDbTable(): No database table given.");
        } else {
            $this->dbTable = $dbTable;
        }
    }

ilElementList::setIdField ( idField  ) 

set unique database field

Parameters:
string $idField unique database field
See also:
$idField private

Definition at line 159 of file class.ilElementList.php.

References $idField.

                                  {
        if ($idField == "") {
            die ("Liste::setIdField(): No id given.");
        } else {
            $this->idField = $idField;
        }
    }

ilElementList::setOrderDirection ( orderDirection  ) 

set sorting direction for results: ASC or DESC

Parameters:
string $orderDirection sorting direction
Returns:
boolean false if parameter is whether ASC nor DESC
See also:
$orderDirection private

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

Parameters:
string $orderField database field for sorting
See also:
$orderField private

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

Parameters:
string $where condition for result fields
See also:
$whereCond private

Definition at line 173 of file class.ilElementList.php.

                                  {
        if ($where == "") {
            die ("Liste::setWhereCond(): No where condition given.");
        } else {
            $this->whereCond = $where;
        }
    }


Field Documentation

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
ilElementList::$whereCond = "1"

Definition at line 70 of file class.ilElementList.php.


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