Location: PHPKode > projects > ChurchCMS > churchcms/lib/db.inc.php
<?php
/**************************************************************************************************
 *                                            ChurchCMS
 * Copyright (C) 2005 jsvoyager
 *
 * Developers & Contributors:
 * jsvoyager					hide@address.com
 *
 * This program is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software Foundation;
 * either version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * (license.txt)
 ***************************************************************************************************/

class mysqldb {
	var $db;
	/*******************************************************
	 * Format for $QueryHistory:
	 * ($i = Number of Query)
	 * $QueryHistory[$i]['query'] = The Query
	 * $QueryHistory[$i]['file'] = File of origion
	 * $QueryHistory[$i]['line'] = Line Within the file
	 *******************************************************/
	var $QueryHistory;
	var $NumQuery = 0;
	
	function connect($server, $username, $pass, $dbname){
		$this->db = @mysql_connect($server, $username, $pass)
		  or error(201, __FILE__, __LINE__, true);
		 @mysql_select_db($dbname, $this->db)
		  or error (203, __FILE__, __LINE, true);
	}
	
	function query($file, $line, $query){
		$result = @mysql_query($query, $this->db)
		 or error(202, $file, $line, true, $query);
		
		$this->NumQuery++;
		$this->QueryHistory[$this->NumQuery]['query'] = $query;
		$this->QueryHistory[$this->NumQuery]['file'] = $file;
		$this->QueryHistory[$this->NumQuery]['line'] = $line;
			
		return $result;
	}
	
	function results($result){
		//Build Result
		$answer = mysql_fetch_array($result);
		
		return $answer;

	}
	
	function field_type($table, $field){
		$query = "SHOW COLUMNS FROM $table";
		$result = @mysql_query($query, $this->db)
		 or error(202, __FILE__, __LINE__, true, $query);
		
		//Figure out which one is the field we are looking for
		while ($field = mysql_fetch_array($result)){
			if ($field['Field'] == $field){
				$answer = $field['type'];
				break;
			}
		}
		
		return ($answer="") ? (false) : ($answer); 
		
	}

	
}
?>
Return current item: ChurchCMS