query($query); } /* public: some trivial reporting */ function link_id() { return $this->Link_ID; } function query_id() { return $this->Query_ID; } /* public: connection management */ function connect($Database = "", $Host = "", $User = "", $Password = "") { /* Handle defaults */ if ("" == $Database) $Database = $this->Database; if ("" == $Host) $Host = $this->Host; if ("" == $User) $User = $this->User; if ("" == $Password) $Password = $this->Password; /* establish connection, select database */ if ( 0 == $this->Link_ID ) { $this->Link_ID=mysql_pconnect($Host, $User, $Password); if (!$this->Link_ID) { $this->halt("pconnect($Host, $User, \$Password) failed."); return 0; } if (!@mysql_select_db($Database,$this->Link_ID)) { $this->halt("Az adatbázis nem használható ".$Database); return 0; } } return $this->Link_ID; } /* public: discard the query result */ function free() { @mysql_free_result($this->Query_ID); $this->Query_ID = 0; } /* public: perform a query */ function query($Query_String) { /* No empty queries, please, since PHP4 chokes on them. */ if ($Query_String == "") /* The empty query string is passed on from the constructor, * when calling the class without a query, e.g. in situations * like these: '$db = new DB_Sql_Subclass;' */ return 0; if (!$this->connect()) { return 0; /* we already complained in connect() about that. */ }; # New query, discard previous result. if ($this->Query_ID) { $this->free(); } if ($this->Debug) printf("Debug: query = %s
\n", $Query_String); $this->Query_ID = @mysql_query($Query_String,$this->Link_ID); $this->Row = 0; $this->Errno = mysql_errno(); $this->Error = mysql_error(); if (!$this->Query_ID) { $this->halt("Hibás SQL: ".$Query_String); } # Will return nada if it fails. That's fine. return $this->Query_ID; } /* public: walk result set */ function next_record() { if (!$this->Query_ID) { $this->halt("next_record called with no query pending."); return 0; } $this->Record = @mysql_fetch_array($this->Query_ID); $this->Row += 1; $this->Errno = mysql_errno(); $this->Error = mysql_error(); $stat = is_array($this->Record); if (!$stat && $this->Auto_Free) { $this->free(); } return $stat; } /* public: position in result set */ function seek($pos = 0) { $status = @mysql_data_seek($this->Query_ID, $pos); if ($status) $this->Row = $pos; else { $this->halt("seek($pos) failed: result has ".$this->num_rows()." rows."); /* half assed attempt to save the day, * but do not consider this documented or even * desireable behaviour. */ @mysql_data_seek($this->Query_ID, $this->num_rows()); $this->Row = $this->num_rows(); return 0; } return 1; } /* public: table locking */ function lock($table, $mode = "write") { $query = "lock tables "; if (is_array($table)) { while (list($key,$value) = each($table)) { if (!is_int($key)) { // texts key are "read", "read local", "write", "low priority write" $query .= "$value $key, "; } else { $query .= "$value $mode, "; } } $query = substr($query,0,-2); } else { $query .= "$table $mode"; } $res = $this->query($query); if (!$res) { $this->halt("lock() failed."); return 0; } return $res; } function unlock() { $res = $this->query("unlock tables"); if (!$res) { $this->halt("unlock() failed."); } return $res; } /* public: evaluate the result (size, width) */ function affected_rows() { return @mysql_affected_rows($this->Link_ID); } function num_rows() { return @mysql_num_rows($this->Query_ID); } function num_fields() { return @mysql_num_fields($this->Query_ID); } /* public: shorthand notation */ function nf() { return $this->num_rows(); } function np() { print $this->num_rows(); } function f($Name) { if (isset($this->Record[$Name])) { return $this->Record[$Name]; } } function p($Name) { if (isset($this->Record[$Name])) { print htmlspecialchars($this->Record[$Name]); } } /* public: sequence numbers */ function nextid($seq_name) { $this->connect(); if ($this->lock($this->Seq_Table)) { /* get sequence number (locked) and increment */ $q = sprintf("select nextid from %s where seq_name = '%s'", $this->Seq_Table, $seq_name); $id = @mysql_query($q, $this->Link_ID); $res = @mysql_fetch_array($id); /* No current value, make one */ if (!is_array($res)) { $currentid = 0; $q = sprintf("insert into %s values('%s', %s)", $this->Seq_Table, $seq_name, $currentid); $id = @mysql_query($q, $this->Link_ID); } else { $currentid = $res["nextid"]; } $nextid = $currentid + 1; $q = sprintf("update %s set nextid = '%s' where seq_name = '%s'", $this->Seq_Table, $nextid, $seq_name); $id = @mysql_query($q, $this->Link_ID); $this->unlock(); } else { $this->halt("cannot lock ".$this->Seq_Table." - has it been created?"); return 0; } return $nextid; } /* public: find available table names */ function table_names() { $this->connect(); $h = @mysql_query("show tables", $this->Link_ID); $i = 0; while ($info = @mysql_fetch_row($h)) { $return[$i]["table_name"] = $info[0]; $return[$i]["tablespace_name"] = $this->Database; $return[$i]["database"] = $this->Database; $i++; } @mysql_free_result($h); return $return; } /* private: error handling */ function halt($msg) { $this->Error = @mysql_error($this->Link_ID); $this->Errno = @mysql_errno($this->Link_ID); if ($this->Halt_On_Error == "no") return; $this->haltmsg($msg); if ($this->Halt_On_Error != "report") die(""); } function haltmsg($msg) { printf("Rendszer üzenet:
%s
\n", $msg); printf("SQL hiba: %s (%s)
\n", $this->Errno, $this->Error); printf("\n
Vissza"); } function recnev($sqln,$MezoNev){ $Mezo=null; $this->Halt_On_Error = "no"; $this->query($sqln); while ($this->next_record()) { $Mezo=htmlspecialchars($this->Record[$MezoNev]); } return $Mezo; } function KombList($ListNev="",$TablaNev,$MezoNev1,$MezoNev2,$AlapErtek=""){ if (!$ListNev=="") { echo ""; } function KombList1($ListNev='lista',$TablaNev,$MezoNev,$AlapErtek=""){ echo ""; } } //**************class end function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } function uzeno($uzen = "", $uzenfej = "", $zz=0) { $feat='width=300,height=150'; echo ""; exit; } function mysql_die($error = "",$zz=0) { global $strError,$strSQLQuery, $strMySQLSaid, $strBack, $sql_query; echo " $strError

"; if (!empty($sql_query)) { echo "$strSQLQuery: [$edit_link]

".htmlspecialchars($sql_query)."

"; } if(empty($error)) echo "$strMySQLSaid ".mysql_error(); else echo "$strMySQLSaid ".htmlspecialchars($error); echo "

"; if ($zz) { echo(""); //echo(""); } else { echo(""); } echo ""; include("./footer.php"); exit; } function locOpen($page){ echo ""; } ?>