buenas necesito ayuda tengo problemas con este módulo del sistema, el estaba funciuonando bien pero de un dia otro me comenzo a dar este error de sintanxis: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND jornada_id=263' at line 1
<?php
class JornadaDetalle {
protected $handle;
public $jornada;
public $proveedor;
public $estudiante;
public $fecha;
public $pos;
public function __construct() {
$conn = new Conexion();
$this->handle = $conn->conect();
}
public function insertEstJornada()
{
$query = "SELECT * FROM jornada_detalle WHERE
jornada_id=".$this->jornada." AND
estudiante_id=".$this->estudiante;
$result = $this->handle->query($query) or die ("Error: ".$this->handle->error);
if($result->num_rows>0){
return false;
}else{
$this->fecha = date('Y-m-d H:i:s');
$query = "INSERT INTO jornada_detalle(jornada_id,proveedor_id, estudiante_id, fecha, pos)
VALUES({$this->jornada}, {$this->proveedor}, {$this->estudiante}, '{$this->fecha}',{$this->pos}) ";
$result = $this->handle->query($query) or die($this->handle->error);
if(!$result)
return false;
return true;
}
}
public function ConsultEstudienteProcesado()
{
$query = "SELECT e.cedula, e.nombre,e.apellido, jd.fecha, p.nombre as nombrep FROM jornada_detalle as jd,estudiante as e, proveedor as p
WHERE jd.estudiante_id = e.cedula AND
p.id = jd.proveedor_id AND
jd.jornada_id={$this->jornada}
ORDER BY fecha DESC ";
$result = $this->handle->query($query) or die ("Error: ".$this->handle->error);
$i = $result->num_rows;
while($datos = $result->fetch_array()){
if($datos['cedula']==$this->estudiante){
$estudiante = "posición: {$i}, {$datos['nombre']} {$datos['apellido']} Fecha: {$datos['fecha']}";
return $estudiante;
}
$i--;
}
}
public function viewJornada()
{
$query = "SELECT e.cedula, e.nombre,e.apellido, jd.fecha, p.nombre as nombrep FROM jornada_detalle as jd,estudiante as e, proveedor as p
WHERE jd.estudiante_id = e.cedula AND
p.id = jd.proveedor_id AND
jd.jornada_id={$this->jornada}
ORDER BY fecha DESC ";
$result = $this->handle->query($query) or die ($this->handle->error);
if(!$result)
return false;
return $result;
}
public function viewJornadaEstud()
{
$query = "SELECT e.cedula, e.nombre,e.apellido, jd.fecha,jd.pos, p.nombre as nombrep, esp.descripcion FROM jornada_detalle as jd,estudiante as e, proveedor as p, especialidad as esp
WHERE e.cedula='{$this->estudiante}' AND
jd.estudiante_id = e.cedula AND
esp.codigo = e.especialidad_id AND
p.id = jd.proveedor_id AND
jd.jornada_id={$this->jornada}
ORDER BY fecha DESC ";
$result = $this->handle->query($query) or die ($this->handle->error);
if(!$result)
return false;
return $result->fetch_assoc();
}
public function countBandejaProveedor($proveedor, $jornada){
$query = "SELECT * FROM jornada_detalle WHERE proveedor_id={$proveedor} AND jornada_id={$jornada} ";
$result = $this->handle->query($query) or die ($this->handle->error);
return $result->num_rows;
}
public function countBandejaProveedorRepor($proveedor, $mes, $year){
$query = "SELECT * FROM jornada_detalle WHERE proveedor_id={$proveedor} AND MONTH(fecha)='$mes' AND YEAR(fecha)='$year'";
$result = $this->handle->query($query) or die ($this->handle->error);
return $result->num_rows;
}
public function viewJornadaReport()
{
$query = "SELECT e.cedula, e.nombre,e.apellido, e.sexo, e.turno, jd.fecha, p.nombre as nombrep, esp.descripcion FROM jornada_detalle as jd,estudiante as e, proveedor as p, especialidad as esp
WHERE jd.estudiante_id = e.cedula AND
esp.codigo = e.especialidad_id AND
jd.proveedor_id = {$this->proveedor} AND
p.id = jd.proveedor_id AND
jd.jornada_id={$this->jornada}
ORDER BY fecha DESC ";
$result = $this->handle->query($query) or die ($this->handle->error);
if(!$result)
return false;
return $result;
}
public function ObtenerFechaHistorico()
{
$query = "SELECT * FROM jornada_detalle_hist WHERE fecha=(SELECT MAX(fecha) FROM jornada_detalle_hist)";
$result = $this->handle->query($query) or die($this->handle->error);
if(!$result)
return false;
$fecha = $result->fetch_assoc();
return $fecha['fecha'];
}
public function totalEstAPasar()
{
$query = "SELECT * FROM estudiante as t1 WHERE t1.cedula NOT IN (SELECT t2.cedula FROM estudiante_hist as t2)
ORDER BY t1.cedula ASC";
$result = $this->handle->query($query) or die($this->handle->error);
if(!$result)
return false;
return $result->num_rows;
}
public function totalJornadaDet()
{
$query = "SELECT * FROM jornada_detalle";
$result = $this->handle->query($query) or die($this->handle->error);
if(!$result)
return false;
return $result->num_rows;
}
public function pasarHist()
{
$query1 = "INSERT INTO estudiante_hist(especialidad_id, cedula, nombre, apellido, sexo, turno)
SELECT t1.especialidad_id, t1.cedula, t1.nombre, t1.apellido, t1.sexo, t1.turno FROM estudiante as t1 WHERE t1.cedula NOT IN (SELECT t2.cedula FROM estudiante_hist as t2)";
$result = $this->handle->query($query1) or die($this->handle->error);
if(!$result)
return false;
$estudAfect = $this->handle->affected_rows;
$query2 = "INSERT INTO jornada_detalle_hist(jornada_id, estudiante_id, proveedor_id, fecha,pos)
SELECT t1.jornada_id, t1.estudiante_id, t1.proveedor_id, t1.fecha, t1.pos FROM jornada_detalle as t1";
$result2 = $this->handle->query($query2) or die($this->handle->error);
if(!$result2)
return false;
$jorndaAfet = $this->handle->affected_rows;
$query3 = "DELETE FROM jornada_detalle";
$query4 = "DELETE FROM estudiante";
$result3 = $this->handle->query($query3) or die('query3 '.$this->handle->error);
if($result3)
$result4 = $this->handle->query ($query4) or die('query4 '.$this->handle->error);
if($result4)
return "Estudiante: $estudAfect, Jornadas: $jorndaAfet";
}
}
?>