ok

Mini Shell

Direktori : /home/institutonamaste/www/admin/class/
Upload File :
Current File : /home/institutonamaste/www/admin/class/DB_database.php

<?php 
	function DBExecute($query, $verid = FALSE)
	{
		$conn 	= DBConnect();
		$result = mysqli_query($conn, $query) or die(/*"Ocorreu um erro inesperado em nosso site, tente novamente ou nos comunique o problema."*/mysqli_error($conn));
		
		if($verid)
			$result = mysqli_insert_id($conn);	

		DBClose($conn);
		return $result;
	}
	
	function DBRead($table, $params = NULL, $fields = '*')
	{
		$table 	= DB_PREFIX.'_'.$table;
		$params = ($params) ? " {$params}" : NULL;
		
		$query 	= "SELECT {$fields} FROM {$table}{$params}";
		$result = DBExecute($query);
		
		return $result;
		
	}
	
	function DBInsert($table, array $data, $verid = FALSE)
	{
		$table 	= DB_PREFIX.'_'.$table;
		$data 	= DBEscape($data);
		
		$coluna = implode(', ', array_keys($data));
		$valor	= "'".implode("', '", $data)."'";
		
		$query	= "INSERT INTO {$table} ( {$coluna} ) VALUES ( {$valor} )";
		
		return DBExecute($query, $verid);	
	}
	
	function DBUpDate($table, array $data, $where = NULL, $verid = FALSE)
	{
		$data 	= DBEscape($data);
		foreach($data as $key => $value){
			$fields[] = "{$key} = '{$value}'";
		}
		
		$fields = implode(", ", $fields);
		
		$table 	= DB_PREFIX.'_'.$table;
		$where	= ($where) ? " {$where}" : NULL;
		
		$query 	= "UPDATE {$table} SET {$fields}{$where}";

		return DBExecute($query, $verid);	
	}
	
?>

Zerion Mini Shell 1.0