Advertisement
yagami07

clasa conexion

Feb 25th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1.  
  2. <?php
  3. class bd {
  4. public $conexion;
  5. public function conexion(){
  6. $this->conexion = new mysqli('localhost','root','','sagaz');
  7.  
  8. if (mysqli_connect_error()) {
  9. die('Error de Conexión (' . mysqli_connect_errno() . ') '
  10. . mysqli_connect_error());
  11. }
  12.  
  13. echo 'Éxito...';
  14.  
  15. return $this->conexion;
  16. }
  17.  
  18. public function consulta(){
  19.  
  20. $query = ("select * from tabla");
  21. $conexion2 = $this->conexion;
  22. $ejecutar = mysqli_query($conexion2,$query);
  23.  
  24. if ($ejecutar != '0'){
  25. echo "entro";
  26.  
  27. }
  28. else {
  29. echo "no entro";
  30. }
  31.  
  32. }
  33. }
  34. $mostrarconexion = new bd();
  35. $mostrarconexion->conexion();
  36. $mostrarconexion->consulta();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement