本文整理匯總了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;
}
}
}