mysql – fatal error: can not redeclare class connection

I have a problem that is a mystery to me, in my hosting Locaweb a site that was functioning normally yesterday morning started to report a connection error, I have not yet contacted their support because this same error occurred 1 month behind and asked for a restore files and everything worked again but without any further explanation from the company.
I would like to be able to understand what is happening. I've already looked for the error and found that it was possible that the login file be declared 2 times, but as I said, the site was working, so I came here to expose my doubts.

My index page has this setting:

if (! isset ($ _SESSION)) {
session_start ();
}

// Requires a connection class
include_once ("_ classes / connect.class.php");
include_once ("_ classes / crud.dsc.class.php");

// PDO connection instance
$ connection = Connection :: getInstance ();
$ crud = Crud :: getInstance ($ connection);

The name called connection_pdo.class.php is:




include_once (& # 39; _ connections / config_db.php & # 39;);

Connection class {
/ *
* Static attribute for PDO instance
* /

static static $ pdo;

/ *
Hide the class constructor
* /

private function __construct () {

}

/ *
* Static method to return a valid connection
* Check if an instance of the connection already exists, otherwise configure a new connection
* /

public static function getInstance () {
if (! isset (self :: $ pdo)) {
try {
$ options = array (PDO :: MYSQL_ATTR_INIT_COMMAND => SET NAMES UTF8 #, PDO :: ATTR_PERSISTENT => TRUE);
self: $ pdo = new PDO ("mysql: host =" .HOST. "; dbname =". DBNAME. "; charset =".
} catch (PDOException $ e) {
displays "Error:". $ e-> getMessage ();
}
}
return self :: $ pdo;
}

}

My page config_db.php looks like this:




define (& # 39; HOST & # 39; my hosts & # 39;);
define ('USER', 'user');
define ("PASSWORD & # 39; password & # 39;);
define (& # 39; DBNAME & # 39 ;, & # 39; bank & # 39;);
define (& # 39; TYPEDB & # 39 ;, & quot; mysql & # 39;)
define (& # 39; CHARSET & # 39 ;, & # 39; utf8 & # 39;);

The page crud.dsc.class.php looks like this:




Crud class {

// Attribute to register a PDO connection
private $ pdo = null;
// static attribute that contains an instance of the class itself
private static $ crud = null;

/ *
* Private class constructor method
* @param $ connection = configured PDO connection
* @param $ table = name of the table
* /

private function __construct ($ connection) {

if (! empty ($ connection)):
$ this-> pdo = $ connection;
if not:
echo "

The connection does not exist!

"; exit (); endif; } / * * Static public method that returns an instance of the Crud class * @param $ connection = configured PDO connection * @param $ table = name of the table * @return Attribute containing the instance of the Crud class * / Public static function getInstance ($ connection) { // Check if an instance of the class exists if (! isset (self :: $ crud)): try { self :: $ crud = new Crud ($ connection); } catch (Exception $ e) { echo "Error". $ e-> getMessage (); } endif; return yourself :: $ crud; } / * * Private method for building INSERT SQL statement * @param $ arrayData = Data array containing columns and values * @return String containing an SQL statement * / private function buildInsert ($ table, $ arrayData) { // Initialize the variables $ sql = ""; $ fields = ""; $ values ​​= ""; // Loop to assemble a declaration with fields and values foreach ($ arrayData as $ key => $ value): $ fields. = $ key. & # 39; & # 39 ;; $ values. = & # 39;?, & # 39 ;; end of each // remove the comma from the end of the string $ fields = (substr ($ fields, -2) ==, & # 39;) trim (substr ($ fields, 0, (strlen ($ fields) - 2))): $ fields; // remove the comma from the end of the string $ values ​​= (substr ($ values, -2) == & # 39;) trim (substr ($ values, 0, (strlen ($ values) - 2))): $ values; // concatenates all variables and ends the statement $ sql. = "INSERT INTO". $ table. "(". $ fields. ") VALUES (". $ values. ")"; // return a string with an SQL statement return plate ($ sql); } / * * Private method for constructing a SQL UPDATE statement * @param $ arrayData = Data array containing columns, operators, and values * @param $ arrayCondicao = Data array containing columns and values ​​for the WHERE condition * @return String containing an SQL statement * / private function buildUpdate ($ table, $ arrayData, $ arrayCondicao) { // Initialize the variables $ sql = ""; $ valCampos = ""; $ valCondicao = ""; // Loop to assemble a declaration with fields and values foreach ($ arrayData as $ key => $ value): $ valCampos. = $ key. & # 39; = & # 39; & # 39 ;; end of each // Loop to set the WHERE condition foreach ($ arrayCount $ as key => $ value): $ valCondage = $ key. & # 39 ;? AND & # 39 ;; end of each // remove the comma from the end of the string $ valCampos = (substr ($ valCampos, -2) == & # 39;) trim (substr ($ valCampos, 0, (strlen ($ valCampos) - 2))): $ valCampos; // remove the comma from the end of the string $ valCondicao = (substr ($ valCondicao, -4) == AND & # 39;)? trim (substr ($ valCondicao, 0, (strlen ($ valCondicao - 4)))): valCondicao; // concatenates all variables and ends the statement $ sql. = "UPDATE". $ table. "SET". $ valCampos. "O" $ valCondicao; // return a string with an SQL statement return plate ($ sql); } / * * Private method to build DELETE SQL statement * @param $ arrayCondicao = Data array containing columns, operators, and values ​​for the WHERE condition * @return String containing an SQL statement * / private function buildDelete ($ table, $ arrayCondicao) { // Initialize the variables $ sql = ""; $ valCampos = ""; // Loop to assemble a declaration with fields and values foreach ($ arrayCount $ as key => $ value): $ valCampos. = $ key. & # 39 ;? AND & # 39 ;; end of each // remove the word AND from the end of the string $ valCampos = (substr ($ valCampos, -4) == AND & # 39;) trim (substr ($ valCampos, 0, (strlen ($ valCampos) - 4))): $ valCampos; // concatenates all variables and ends the statement $ sql. = "DELETE FROM". $ table. "O" $ valCampos; // return a string with an SQL statement return plate ($ sql); } / * * Public method for inserting data into a table * @param $ arrayData = Data array containing columns and values * @return Returns the Boolean result of the SQL statement * / public function insert ($ table, $ arrayData) { try { // Assign the built-in SQL method to the statement $ sql = $ this-> buildInsert ($ table, $ arrayData); // pass the instruction to the PDO $ stm = $ this-> pdo-> prepare ($ sql); // Loop to pass the data in parameter $ cont = 1; foreach ($ arrayData as $ value): $ stm-> bindValue ($ cont, $ value); $ cont ++; end of each // Execute the SQL statement and capture the return $ return = $ stm-> execute (); return $ return; } catch (PDOException $ e) { echo "Error:". $ e-> getMessage (); } } / * * Public method to update table data * @param $ arrayData = Data array containing columns and values * @param $ arrayCondicao = Data array containing columns and values ​​for condition WHERE - Example array (& # 39; $ id = & # 39; => 1) * @return Returns the Boolean result of the SQL statement * / public function update ($ table, $ arrayData, $ arrayCondicao) { try { // Assign the built-in SQL method to the statement $ sql = $ this-> buildUpdate ($ table, $ arrayData, $ arrayCondage); // pass the instruction to the PDO $ stm = $ this-> pdo-> prepare ($ sql); // Loop to pass the data in parameter $ cont = 1; foreach ($ arrayData as $ value): $ stm-> bindValue ($ cont, $ value); $ cont ++; end of each // Loop to pass data as parameter WHERE clause foreach ($ arrayCode as $ value): $ stm-> bindValue ($ cont, $ value); $ cont ++; end of each // Execute the SQL statement and capture the return $ return = $ stm-> execute (); return $ return; } catch (PDOException $ e) { echo "Error:". $ e-> getMessage (); } } / * * Public method to delete data from the table * @param $ arrayCondicao = Data array containing columns and values ​​for condition WHERE - Example array (& # 39; $ id = & # 39; => 1) * @return Returns the Boolean result of the SQL statement * / public function delete ($ table, $ arrayCondicao) { try { // Assign the built-in SQL method to the statement $ sql = $ this-> buildDelete ($ table, $ arrayCondicao); // pass the instruction to the PDO $ stm = $ this-> pdo-> prepare ($ sql); // Loop to pass data as parameter WHERE clause $ cont = 1; foreach ($ arrayCode as $ value): $ stm-> bindValue ($ cont, $ value); $ cont ++; end of each // Execute the SQL statement and capture the return $ return = $ stm-> execute (); return $ return; } catch (PDOException $ e) { echo "Error:". $ e-> getMessage (); } } / * * Generic method to execute query statements independent of the name of the table passed in _construct * @param $ sql = Complete SQL statement containing, names of involved tables, JOINS, WHERE, ORDER BY, GROUP BY and LIMIT * @param $ arrayParam = Array containing only the parameters needed by the WHERE class * @param $ fetchAll = Boolean value with the default value TRUE indicating that multiple rows will be returned, FALSE returns only the first line. * @return Returns an array of query data in the form of objects. * / public function getSQLGeneric ($ sql, $ arrayParams = null, $ fetchAll = TRUE) { try { // pass the instruction to the PDO $ stm = $ this-> pdo-> prepare ($ sql); // check if there are conditions to load parameters if (! empty ($ arrayParams)): // Loop to pass data as parameter WHERE clause $ cont = 1; foreach ($ arrayParams as $ value): $ stm-> bindValue ($ cont, $ value); $ cont ++; end of each endif; // Execute the SQL statement $ stm-> execute (); // Check if multiple rows should be returned if ($ fetchAll): $ data = $ stm-> fetchAll (PDO :: FETCH_OBJ); if not: $ data = $ stm-> fetch (PDO :: FETCH_OBJ); endif; returns $ data; } catch (PDOException $ e) { echo "Error:". $ e-> getMessage (); } } }

If anyone can help me understand, thank you.