note 106842 added to function.mysql-connect

From: Date: Sun, 11 Dec 2011 19:14:34 +0000
Subject: note 106842 added to function.mysql-connect
Groups: php.notes 
Request: Send a blank email to php-notes+get-185040@lists.php.net to get a copy of this message
<?php class Connection { private $connection; private $hostname; private $port; private $username; private $password; private $database; /** * Metodo para abrir la conexion con el servicio de MySql PHP * @return the $connection openned */ public function OpenMySQLConnection() { $this->hostname = "localhost"; $this->username = "root"; // only example $this->password = "root"; // only example $this->database = "name_database"; $this->connection = (mysql_connect($this->hostname, $this->username, $this->password)); if(!($this->connection)) { die('ERROR CONNECTION:<br/>Error al conectarse con la Base de Datos: '.mysql_error()."<br/>DETALLE ERROR:<br/>".mysql_error()); exit(); return false; } else { if(!(mysql_select_db($this->database, $this->connection))) { die('ERROR SELECT DATABASE:<br/>Error al seleccionar la Base de Datos: '.mysql_error()."<br/>DETALLE ERROR:<br/>".mysql_error()); exit(); return false; } else { return $this->connection; } } } /** * Metodo que ejecuta sentencias (INSERT, UPDATE & DELETE) y devuelve un resultado * @param $prepareStatement or $query * @return the $resultSet */ public function ExecuteUpdate($prepareStatement) { if(!($prepareStatement)) { echo 'ERROR QUERY:<br/>Error recibir prepareStatement '.mysql_error()."<br/>DETALLE ERROR:<br/>".mysql_error(); exit(); return false; } else { $resultSet = mysql_query($prepareStatement, $this->connection); if(!($resultSet)) { echo 'ERROR EXECUTE QUERY:\n Error al ejecutar prepareStatement'.mysql_error()."\n DETALLE ERROR:\n".mysql_error(); exit(); return false; } else { return $resultSet; } } } /** * Metodo que ejecuta SELECT y devuelve un resultado * @param $statement or $query * @return the $resultSet */ public function ExecuteQuery($statement) { if(!($statement)) { echo 'ERROR QUERY:\n Error recibir statement '.mysql_error()."\n DETALLE ERROR:\n".mysql_error(); exit(); return false; } else { $resultSet = mysql_query($statement, $this->connection); if(!($resultSet)) { echo 'ERROR EXECUTE QUERY:\n Error al ejecutar statement '.mysql_error()."\n DETALLE ERROR:\n".mysql_error(); exit(); return false; } else { return $resultSet; } } } /** * Metodo que guarda las sentencias para mostrarlas * @param $statement or $query * @return the $resultSet */ public function ResultSet($statement) { if(!($statement)) { echo 'ERROR RESULTSET QUERY:\n Error al sentencia esta vacia o errada '.mysql_error()."\n DETALLE ERROR:\n".mysql_error(); exit(); return false; } else { $resultSet = mysql_fetch_array($statement); if(!($resultSet)) { echo 'ERROR RESULTSET:\n Error al resultSet esta vacio '.mysql_error()."\n DETALLE ERROR:\n".mysql_error(); exit(); return false; } else { return $resultSet; } } } /** * Metodo para cerrar la conexion con el servicio de MySql PHP * @return the $connection closed */ public function CloseMySQLConnection() { mysql_close($this->connection); } ---- Server IP: 69.147.83.197 Probable Submitter: 190.208.98.217 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-connect.php Edit -- https://master.php.net/note/edit/106842 Del: integrated -- https://master.php.net/note/delete/106842/integrated Del: useless -- https://master.php.net/note/delete/106842/useless Del: bad code -- https://master.php.net/note/delete/106842/bad+code Del: spam -- https://master.php.net/note/delete/106842/spam Del: non-english -- https://master.php.net/note/delete/106842/non-english Del: in docs -- https://master.php.net/note/delete/106842/in+docs Del: other reasons-- https://master.php.net/note/delete/106842 Reject -- https://master.php.net/note/reject/106842 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#185040) next »