Location: PHPKode > scripts > SMVC > smvc/_smvc/driver/oracle.php
<?php  if ( ! defined('PATH')) exit('Acesso direto NEGADO');
/**
 * Smvc - Simple MVC
 * @name	Drive-MySql
 * @package SMVC
 * @author Paulo Rocha
 * @copyright 2009 - 2009 Ahcor Design
 * @license		http://smvc.tk/manual/license.html
 * @link		http://smvc.tk
 * @since		Version 0.01
 * @filesource	http://smvc.tk/download
 * @category	Driver
 * @uses		Driver para acesso ao BD Oracle
 */

class DB extends Smvc_db{
	public $db_host;
	public $db_user;
	public $db_password;
	public $db_charset;	
	
	public $conexao;
	
	function __construct()
	{
		//echo "oracle|";
		echo $this->db_charset;
	}

	function connect()
	{
		$this->conexao = oci_connect($this->db_user, $this->db_password, $this->db_host, $this->db_charset);
	}
	
	function query($sql)
	{
		$stmt = oci_parse($this->conexao,$sql);
		if(oci_execute($stmt)){return $stmt;}else{return false;}
	}
	
	function delete($table,$where)
	{
		$sql= "DELETE FROM $table WHERE $where";
		if($this->query($sql)){return oci_commit($this->conexao);}else {return false;}
	}
	
	function insert($table,$array,$where)
	{		
			$sql="INSERT INTO $table  (";
			echo $x=count($array);
			for ($i = 0; $i <= $x; $i++) {
				$a.=key($array); if($i<$x-1){$a.=",";}
				$b.=current($array); if($i<$x-1){$b.=",";}
				next($array);
			}
			$sql.= $a.") VALUES (".$b.")";
			if ($where!=""){$sql.=" WHERE $where ";}
			echo $sql;
			//if($this->query($sql)){return oci_commit($this->conexao);}else{return false;}	
	function update($table,$array,$where)
	{
			$sql="UPDATE $tabela SET ";
			//foreach($array as $key=>$val){$sql.=$key."=".$val.",";}
			$x=count($array);
			for ($i = 1; $i <= $x; $i++) {
				$sql.=key($array)."=".current($array); if($i<=$x-1){$sql.=",";}
				next($array);
			}
			if($where!=""){$sql.= "  WHERE $where ";}
			echo $sql;
			//if($this->query($sql)){return oci_commint($this->conexao);}else{return false;}
			
		}
	}	
	
	/**
	* @name dbDelete
	* @param string $table Tabela onde a linha será apagada
	* @param string $where condição 'sql' para a ação
	* @return bool retorna true ou false
	*/
		function __call($m, $a)
    		{
    		    //print "Método $m chamado:\n";
    		    //var_dump($a);
   		     return $this->x;
			}
}
?>
Return current item: SMVC