I'm starting to code a web platform with php 5.3 + MySQL and i'm trying to coded this abstract class
- Code: Select all
include_once '../eEstadoConexion.php'; // --> Enum for connections states
class cConexionMySQL
{
// Atributos
private $_IP_Servidor;
private $_Nombre_DB;
private $_Puerto;
private $_NombreUsuario;
private $_Password;
private $_Conexion = NULL;
private $_EstadoConexion = eEstadoConexion::_Cerrada;
private static $_Instancia = NULL ;
// Getters ...
// Setters ...
// Other functions ...
}
I extended the class cUsuarioMySQL from the class i just wrote.
- Code: Select all
include_once "../abstractas/cConexionMySQL.php";
final class cUsuarioMySQL extends cConexionMySQL
{
// Atributos
private static $_Instancia = NULL;
private $_SQL_ValidarUsuario = "call sp_Veterinaria_ValidarUsuario(?,?, @registro)";
// Constructor
private function __construct ( )
{
}
// Obtenedor de instancia
public static function obtenerInstancia ( $pIP_Servidor, $pNombre_DB, $pPuerto, $pNombreUsuario, $pPassword )
{
if ( !( self::$_Instancia instanceof self) )
{
self::$_Instancia = new self ( );
self::$_Instancia -> setIP ( $pIP_Servidor, $pPuerto );
self::$_Instancia -> setNombreDB ( $pNombreDB );
self::$_Instancia -> setNombreUsuario ( $pNombreUsuario, $pPassword );
}
return self::$_Instancia;
}
// Other functions ...
}
And this is the way i used the extended class..
- Code: Select all
<?php
include_once 'clases/datos/cUsuarioMySQL.php';
$nombre = "user";
$password = "password";
try
{
$conexion = cUsuarioMySQL::obtenerInstancia("localhost", "db", 3306, "user", "password" );
}
catch( Exception $ex )
{
echo $ex -> getMessage ( );
}
?>
And here it is the problem... When i execute the code i keep getting a Error de HTTP 500 (Internal Server Error) from google chrome (Also tried this on firefox and i get the same result) and i don't know why, yet. I googled and the way i coded isn't wrong as far as i know. I tried also to change the singletton pattern to the class that extend the cConexionMySQL class. Also tried changing the self
Someone know where is the bug ???
Thanks.



