Go to the documentation of this file.00001 <?php
00002
00013 class ilCalDBHandler
00014 {
00020 var $ilias;
00021
00028 var $dbTable;
00029
00036 var $className="ilCalDBHandler";
00037
00044 var $orderConstruct;
00045
00052 var $whereCondition;
00053
00060 var $column;
00061
00068 var $number_of_values = 0;
00069
00076 var $values;
00077
00084 var $query;
00085
00092 var $result;
00093
00098 function ilCalDBHandler() {
00099 global $ilias;
00100 $this->ilias =& $ilias;
00101 }
00102
00103
00110 function select($dbTable ,$column="" ,$whereCondition="" ,$orderConstruct="") {
00111 if (strlen($dbTable) == 0) {
00112 die($this->className . "::select(): No dbTable given.");
00113 }
00114 else {
00115 if (strlen($column) == 0) {
00116 $column = "*";
00117 }
00118 if (strlen($orderConstruct) == 0) {
00119 if (strlen($whereCondition) == 0) {
00120 $query = "SELECT {$column} FROM {$dbTable}";
00121 }
00122 else {
00123 $query = "SELECT {$column} FROM {$dbTable} WHERE {$whereCondition}";
00124 }
00125 }
00126 else {
00127 if (strlen($whereCondition) == 0) {
00128 $query = "SELECT {$column} FROM {$dbTable} ORDER BY {$orderConstruct}";
00129 }
00130 else {
00131 $query = "SELECT {$column} FROM {$dbTable} WHERE {$whereCondition} ORDER BY {$orderConstruct}";
00132 }
00133 }
00134 $result = $this->ilias->db->query($query);
00135
00136 return $result;
00137 }
00138 }
00139
00145 function insert($number_of_values, $dbTable, $fields, $values) {
00146 switch ($number_of_values) {
00147 case 0: die($this->className . "::insert(): no number_of_values given.");
00148 break;
00149 case 1: $query = "INSERT INTO {$dbTable} ({$fields}) VALUE ({$values})";
00150 break;
00151 default: $query = "INSERT INTO {$dbTable} ({$fields}) VALUES ({$values})";
00152 }
00153
00154 $result = $this->ilias->db->query($query);
00155 }
00156
00163 function update($dbTable, $values, $whereCondition) {
00164 if (strlen($dbTable) != 0 && strlen($values) != 0 && strlen($whereCondition) != 0) {
00165 $query = "UPDATE {$dbTable} SET {$values} WHERE {$whereCondition}";
00166 $result = $this->ilias->db->query($query);
00167
00168 }
00169 else {
00170 die ($this->className . "::update(): incorrect parameters.");
00171 }
00172 }
00173
00180 function delete($dbTable, $whereCondition, $delete=false) {
00181 if (strlen($dbTable) != 0 && strlen($whereCondition) != 0) {
00182 $query = "DELETE FROM {$dbTable} WHERE {$whereCondition}";
00183 $result = $this->ilias->db->query($query);
00184 }
00185 elseif (strlen($dbTable) != 0 && strlen($whereCondition) == 0 && $delete == true) {
00186 $query = "DELETE FROM {$dbTable}";
00187 $result = $this->ilias->db->query($query);
00188 }
00189 else {
00190 die ($this->className . "::delete(): incorrect parameters.");
00191 }
00192 }
00193
00194 }
00195
00196 ?>