resource); $pole = ""; if ($vysl == "") { echo "SQL class erorr ".mysql_errno().": ".mysql_error()."
"; } while ($row=mysql_fetch_array($vysl,MYSQL_ASSOC)) { $pole[] = $row["Field"]; } mysql_free_result($vysl); return ($pole); } function last_id() { return(mysql_insert_id()); } function parse_podm ($podm,$tabledesc) { if ((gettype($podm[0]) != "array") && (gettype($podm[1]) != "array") && (gettype($podm[2]) != "array")) { if (!in_array($podm[0],$tabledesc)) { $podm[0] = '"'.AddSlashes($podm[0]).'"'; } if (!in_array($podm[2],$tabledesc)) { $podm[2] = '"'.AddSlashes($podm[2]).'"'; } return ($exist."(".$podm[0]." ".$podm[1]." ".$podm[2].")"); } else { return ("(".$this->parse_podm($podm[0],$tabledesc)." ".$podm[1]." ".$this->parse_podm($podm[2],$tabledesc).")"); } } function sql($tr=0) { include("pwd.php"); $this->trace = $tr; $this->resource = mysql_connect($SQL_COMPUTER,$SQL_USERNAME,$SQL_PASSWORD); mysql_select_db($SQL_DATABASE,$this->resource); } function close() { mysql_close ($this->resource); } function select_raw($sql) { if ($this->trace) { echo $sql."
"; } $this->vysledek = mysql_query ($sql,$this->resource); if ($this->vysledek == "") { die ("SQL class erorr ".mysql_errno().": ".mysql_error()."
"); return(false); } return(mysql_num_rows($this->vysledek)); } function select($table,$what,$podm="",$order="") { if (($this->trace == 3) & ($order != "NOTHING!")) { echo "Pocet zaznamu: ".$this->select_count($table,$podm)."
"; } if ($order == "NOTHING!") { $order = ""; } $cm = "select $what from $table "; if ($podm != "") { $cm .= " where $podm"; } if ($order != "") { $cm .= " order by $order"; } if ($this->trace) { echo $cm."
"; } $this->vysledek = mysql_query ($cm,$this->resource); if ($this->vysledek == "") { die ("SQL class erorr ".mysql_errno().": ".mysql_error()."
"); return(false); } return(mysql_num_rows($this->vysledek)); } function execute($cmd) { if ($this->trace) { echo $cmd."
"; } $pom = mysql_query ($cmd,$this->resource); if ($pom == "") { die("SQL class erorr ".mysql_errno().": ".mysql_error()."
"); return false; } else { return true; } } function select_count($table,$podm="") { $this->select ($table,"count(*) as pocet",$podm,"NOTHING!"); $row = $this->result(); $this->done(); return($row["pocet"]); } function delete($table,$podm="") { $cm = "delete from $table"; if ($podm != "") { $cm .= " where $podm"; } if ($this->trace) { echo $cm."
"; } if ($this->trace != 2) { $res = mysql_query ($cm,$this->resource); if ($res) { return(true); } else { return(false); } } } function insert ($table,$values) { $nazvy = ""; $hodnoty = ""; while (list($key,$value) = each ($values)) { if ($nazvy != "") { $nazvy .= ","; $hodnoty .= ","; } if (substr($key,0,1) == "@") { $nazvy .= substr($key,1); $hodnoty .= $value; } else { $nazvy .= $key; $hodnoty .= '"'.AddSlashes($value).'"'; } } $nazvy = "($nazvy)"; $hodnoty = "($hodnoty)"; $cm = "insert into $table $nazvy values $hodnoty"; if ($this->trace) { echo $cm."
"; } if ($this->trace != 2) { $res = mysql_query($cm,$this->resource); if ($res) { return(true); } else { die("SQL class erorr ".mysql_errno().": ".mysql_error()."
"); } } } function update ($table,$values,$podm="") { $cmd = ""; while (list($key,$value) = each ($values)) { if ($cmd != "") { $cmd .= ","; } if (substr($key,0,1) == "@") { $cmd .= substr($key,1)."=".$value; } else { $cmd .= $key."=".'"'.addslashes($value).'"'; } } if ($podm != "") { $pod .= " where $podm"; } $cmd = "update $table set $cmd $pod"; if ($this->trace) { echo $cmd."
"; } if ($this->trace != 2) { $res = mysql_query ($cmd,$this->resource); if ($res) { return(true); } else { die("SQL class erorr ".mysql_errno().": ".mysql_error()."
"); } } } function result() { return (mysql_fetch_assoc($this->vysledek)); } function seek($pos) { mysql_data_seek($this->vysledek,$pos); } function done() { mysql_free_result ($this->vysledek); } } $sql = new sql(0); mysql_query("set character set uft8"); mysql_query("set names uft8"); mysql_query("set character_set_results = utf8"); mysql_query("set character_set_connection = utf8"); mysql_query("set character_set_client = utf8"); ?>