Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/11/2013, 17:17
Avatar de hhs
hhs
Colaborador
 
Fecha de Ingreso: junio-2013
Ubicación: México
Mensajes: 2.995
Antigüedad: 10 años, 10 meses
Puntos: 379
Respuesta: Errores con MySQLi

Cita:
Iniciado por keypyhh Ver Mensaje
Código PHP:
Ver original
  1. protected function abrirConexion() {
  2.         try{
  3.              $this->conexion = new mysqli('localhost', 'root','root', 'latabla');
  4.              if (!$this->conexion) {
  5.                   return false;
  6.              } else {
  7.                   return true;
  8.              }
  9.         } catch (Exception $e){
  10.              return false;
  11.         }
  12.     }

¿Alguna manera de yo saber el error y retornar el false sin que se detenga la ejecución?
Implementando el try.. catch apropiadamente con mysqli_sql_exception: te dejo la liga a la documentación: http://php.net/manual/en/class.mysqli-sql-exception.php
__________________
Saludos
About me
Laraveles
A class should have only one reason to change.