table`"; $source = $this->Query($sql); while($obj = mysql_fetch_object($source)){ $result[] = $obj; } return $result; } //vrátí pole objektů všech prvků v DB seřazených podle order function GetAllOrdered($order){ $sql = "SELECT * FROM `$this->table` ORDER by $order"; $source = $this->Query($sql); while($obj = mysql_fetch_object($source)){ $result[] = $obj; } return $result; } //vrátí pole objektů všech prvků v DB vyhovujících WHERE clausuli function GetAllSelected($where){ $sql = "SELECT * FROM `$this->table` WHERE $where"; $source = $this->Query($sql); while($obj = mysql_fetch_object($source)){ $result[] = $obj; } return $result; } //vrátí pole objektů vyhovujícím podmínce a seřazené podle order function GetSelectedOrdered($where, $order){ $sql = "SELECT * FROM `$this->table` WHERE $where ORDER by $order"; $source = $this->Query($sql); while($obj = mysql_fetch_object($source)){ $result[] = $obj; } return $result; } //vrátí 1 objekt podle hledání a seřazení function GetObjectSelectedOrdered($where, $order){ $sql = "SELECT * FROM `$this->table` WHERE $where ORDER by $order LIMIT 0,1"; $source = $this->Query($sql); return mysql_fetch_object($source); } //vrátí objekt s daným ID function GetObjectById($id){ $sql = "SELECT * FROM `$this->table` WHERE `id` = '$id'"; $source = $this->Query($sql); return mysql_fetch_object($source); } //vrátí do objektu data záznamu s požadovanou hodnotou požadovaného sloupce function GetObjectBySelectedValue($column, $value){ $sql = "SELECT * FROM `$this->table` WHERE `$column` = '$value'"; $source = $this->Query($sql); return mysql_fetch_object($source); } //INSERT FCE //přidá do db záznam function Add($csv){ $sql = "INSERT INTO `$this->table` VALUES ($csv)"; $source = $this->Query($sql); } function addStrange($table, $csv){ $sql = "INSERT INTO `$table` VALUES ($csv)"; $source = $this->Query($sql); } //UPDATE FCE //upraví hodnoty u daného ID podle update řetězce function UpdateById($id, $csv){ $sql = "UPDATE `$this->table` SET $csv WHERE `id` = $id"; $source = $this->Query($sql); } //update podle WHERE Clause function UpdateWhere($where, $csv){ $sql = "UPDATE `$this->table` SET $csv WHERE $where"; $source = $this->Query($sql); } function updateStrangeById($table, $id, $csv){ $sql = "UPDATE `$table` SET $csv WHERE `id` = $id"; $source = $this->Query($sql); } //DELETE FCE function deleteById($id){ $sql = "DELETE FROM `$this->table` WHERE `id` = $id"; $source = $this->Query($sql); } function deleteStrangeById($table, $id){ $sql = "DELETE FROM `$table` WHERE `id` = $id"; $source = $this->Query($sql); } function DeleteWhere($what){ $sql = "DELETE FROM `$this->table` WHERE $what"; $source = $this->Query($sql); } function DeleteStrangeWhere($table, $what){ $sql = "DELETE FROM `$table` WHERE $what"; $source = $this->Query($sql); } //DALŠÍ FCE //vrátí true pokud obsahuje položky function IsItems(){ $sql = "SELECT * FROM `$this->table`"; $source = $this->Query($sql); if(mysql_num_rows($source)) return true; else return false; } function getSetProps($what){ $source = $this->Query("DESCRIBE `$this->table` `$what`"); $obj = mysql_fetch_object($source); $propsString = $obj->Type; $res = explode( "'", $propsString ); $i = 0; while(isset($res[(2*$i)+1])){ $result[$i] = $res[(2*$i)+1]; $i++; } return $result; } //universal query function function getDataBySQL($sql){ $source = $this->Query($sql); $obj = mysql_fetch_object($source); return $obj; } //universal multidata query function function getMultiDataBySQL($sql){ $source = $this->Query($sql); while($obj = mysql_fetch_object($source)){ $result[] = $obj; } return $result; } //zmena display function changeDisplay($id, $display){ $this->UpdateById($id, "`display` = '$display'"); } //zmena poradi function changePoradi($id, $poradi){ $this->UpdateById($id, "`poradi` = '$poradi'"); } function Query($command){ $result = mysql_query($command) or die("Špatný dotaz: " . mysql_error()); return $result; } } ?>