<?php

require_once("BaseDatos.class.php");

class vehiculoBD extends BaseDatos
{
	function vehiculoBD(){}


	function getvehiculos_fecha(){
		$sql="SELECT  * FROM vehiculos order by rand() limit 9;";
		$inventarios=array();
		$this->connectClass();
		$index = $this->query($sql);
		while($row = $this->fetch($index)){
			$i=0;
			$inventarios [] = new vehiculo($row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++]);
		}
		$this->close();
		return $inventarios;
	}
	
	function getbusca_vehiculo($tipo="",$busca=""){
		$sql="SELECT * FROM vehiculos where ".$tipo." = '".$busca."'";
		$vehiculos=array();
		$this->connectClass();
		$index = $this->query($sql);
		while($row = $this->fetch($index)){
			$i=0;
			$vehiculos [] = new vehiculo($row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++]);
		}
		$this->close();
		return $vehiculos;
	}
		function getbusca_avanzada($busca=""){
		$sql="SELECT * FROM vehiculos where marca = '".$busca."' OR modelo = '".$busca."'";
		$vehiculos=array();
		$this->connectClass();
		$index = $this->query($sql);
		while($row = $this->fetch($index)){
			$i=0;
			$vehiculos [] = new vehiculo($row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++]);
		}
		$this->close();
		return $vehiculos;
	}
	function getbusca_vehiculoantiguo(){
		$sql="SELECT * FROM vehiculos where anio < '2000'";
		$vehiculos=array();
		$this->connectClass();
		$index = $this->query($sql);
		while($row = $this->fetch($index)){
			$i=0;
			$vehiculos [] = new vehiculo($row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++]);
		}
		$this->close();
		return $vehiculos;
	}
			function getvehiculo($id=""){
		$sql="SELECT * FROM vehiculos WHERE id ='".$id."'";
		$this->connectClass();
		$index = $this->query($sql);
		$vehiculo = false;
		if($row = $this->fetch($index)){
			$i=0;
			$vehiculo = new vehiculo($row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++],$row[$i++]);
		}
		$this->close();
		return $vehiculo;
	}


	
}
?>
