Location: PHPKode > scripts > MySQL Form Generator > mysql-form-generator/class.mysqldb.php
<?
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#                                                         #
#           MySQLDB Class - The MySQL Form Generator      #
#           Tobie van der Spuy - 2001                     #
#           hide@address.com                          #
#                                                         #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

class MySQLDB {
	  
	  var $name;
	  var $login;
	  var $passwd;
	  var $host;
	  var $conn;
	  var $error;
	  
	  // MySQLDB Constructor <
	  // ---------------------
	  function MySQLDB ($name,$login,$passwd,$host) {

			   if ($host == "") { $host = "localhost"; }
	  		   $this->name = $name;
	  		   $this->type = $type;
	  		   $this->login = $login;
	  		   $this->passwd = $passwd;
			   $this->host = $host;
			   $this->error = "";
			   $this->conn = mysql_connect($this->host,$this->login,$this->passwd);
			   }
   
	  // MySQL Select Database <
	  // -----------------------
   	  function select () {

	  		   mysql_select_db($this->name,$this->conn);
			   }


	  // MySQL Insert and Update <
	  // -------------------------
	  function put ($string) {

	  		   if (mysql_query($string,$this->conn)) {
			   	  return true;
				  }
		 	   else {
			   		$this->error = mysql_error($this->conn);
					return false;
			   		}
	  		   }

	  //  MySQL Select <
	  // ---------------
	  function get($string,$mode) {

			   if ($mode == "") { $mode = "1"; }
			   	  $result = mysql_query($string,$this->conn);
				  $this->error = mysql_error($this->conn);
				  switch ($mode) {
				  		 case 0:
						 	  return $result;
							  break;
				  		 case 1:
						 	  if (mysql_num_rows($result) != "0") {
							  	 $array = mysql_fetch_array($result);
								 return $array;
								 }
							  else { 
							  	   $array = array("0");
								   return $array;
								   }
							  break;
				  		 case 2:
						 	  $rows = mysql_num_rows($result);
							  for ($i = 0; $i < $rows; $i++) {
							  	  $array[$i] = mysql_fetch_array($result);
							  }
							  return $array;
							  break;
						 }
				  }
	  		   }
?>
Return current item: MySQL Form Generator