本文整理汇总了PHP中Connect::lastInsertId方法的典型用法代码示例。如果您正苦于以下问题:PHP Connect::lastInsertId方法的具体用法?PHP Connect::lastInsertId怎么用?PHP Connect::lastInsertId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connect
的用法示例。
在下文中一共展示了Connect::lastInsertId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: guardar
public function guardar()
{
$conexion = new Connect();
$utils = new Utils();
if ($this->con_id) {
$query = 'UPDATE ' . self::DB_TBL_CONFIRMACION . ' SET con_prioridad=:con_prioridad, con_transmision=:con_transmision, con_imagen=:con_imagen, con_informacion=:con_informacion, con_url=:con_url, con_id_reserva=:con_id_reserva, con_id_tipo_evento=:con_id_tipo_evento, con_id_recurso=:con_id_recurso, con_id_canal=:con_id_canal, con_id_usuario=:con_id_usuario WHERE con_id =:con_id';
$consulta = $conexion->prepare($query);
$consulta->bindParam(':con_prioridad', $this->con_prioridad);
$consulta->bindParam(':con_transmision', $this->con_transmision);
$consulta->bindParam(':con_imagen', $this->con_imagen);
$consulta->bindParam(':con_informacion', $this->con_informacion);
$consulta->bindParam(':con_url', $this->con_url);
$consulta->bindParam(':con_id_reserva', $this->con_id_reserva);
$consulta->bindParam(':con_id_tipo_evento', $this->con_id_tipo_evento);
$consulta->bindParam(':con_id_recurso', $this->con_id_recurso);
$consulta->bindParam(':con_id_canal', $this->con_id_canal);
$consulta->bindParam(':con_id_usuario', $this->con_id_usuario);
$consulta->bindParam(':con_id', $this->con_id);
if ($consulta->execute()) {
//echo "<script>alert('Datos actualizados correctamente')</script>";
return 1;
} else {
//echo $consulta->errorCode();
//echo "<script>alert('Error al actualizar datos')</script>";
}
} else {
$query2 = 'INSERT INTO ' . self::DB_TBL_CONFIRMACION . ' ( con_id, con_prioridad, con_transmision, con_imagen, con_informacion, con_url, con_id_reserva, con_id_tipo_evento, con_id_recurso, con_id_canal, con_id_usuario) VALUES( con_id, :con_prioridad, :con_transmision, :con_imagen, :con_informacion, :con_url, :con_id_reserva, :con_id_tipo_evento, :con_id_recurso, :con_id_canal, :con_id_usuario)';
$consulta = $conexion->prepare($query2);
$consulta->bindParam(':con_prioridad', $this->con_prioridad);
$consulta->bindParam(':con_transmision', $this->con_transmision);
$consulta->bindParam(':con_imagen', $this->con_imagen);
$consulta->bindParam(':con_informacion', $this->con_informacion);
$consulta->bindParam(':con_url', $this->con_url);
$consulta->bindParam(':con_id_reserva', $this->con_id_reserva);
$consulta->bindParam(':con_id_tipo_evento', $this->con_id_tipo_evento);
$consulta->bindParam(':con_id_recurso', $this->con_id_recurso);
$consulta->bindParam(':con_id_canal', $this->con_id_canal);
$consulta->bindParam(':con_id_usuario', $this->con_id_usuario);
if ($consulta->execute()) {
$this->con_id = $conexion->lastInsertId();
//echo "<script>alert('Datos actualizados correctamente')</script>";
return 1;
} else {
//echo $consulta->errorCode();
//echo "<script>alert('Error al actualizar datos')</script>";
echo $consulta->errorCode();
return 0;
}
}
}