l-jay

Membres
  • Content count

    1
  • Joined

  • Last visited


Community Reputation

-3 Triste personnage

About l-jay

  • Rank
    Petit nouveau

l-jay's Activity

  1. l-jay added a topic in Développement   

    pdo erreur 2014
    SALUT A TOUS JE SUIS UN PROGRAMMEUR MAIS JE CONNAIS VRAIMENT EN PDO JE SUIS JUSTE DE COMMENCE. JE TRAVAILLE UN PROJET VOICI LA PAGE:



    <?php // Class providing generic data access functionality class DatabaseHandler { // Hold an instance of the PDO class private static $_mHandler; // Private constructor to prevent direct creation of object private function __construct() { } // Return an initialized database handler private static function GetHandler() { // Create a database connection only if one doesn&#39;t already exist if (!isset(self::$_mHandler)) { // Execute code catching potential exceptions try { // Create a new PDO class instance self::$_mHandler = new PDO(PDO_DSN, DB_USERNAME, DB_PASSWORD, array(PDO::ATTR_PERSISTENT => DB_PERSISTENCY)); // Configure PDO to throw exceptions self::$_mHandler->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { // Close the database handler and trigger an error self::Close(); trigger_error($e->getMessage(), E_USER_ERROR); } } // Return the database handler return self::$_mHandler; } // Clear the PDO class instance public static function Close() { self::$_mHandler = null; } // Wrapper method for PDOStatement::execute() public static function Execute($sqlQuery, $params = null) { // Try to execute an SQL query or a stored procedure try { // Get the database handler $database_handler = self::GetHandler(); // Prepare the query for execution $statement_handler = $database_handler->prepare($sqlQuery); // Execute query $statement_handler->execute($params); } // Trigger an error if an exception was thrown when executing the SQL query catch(PDOException $e) { // Close the database handler and trigger an error self::Close(); trigger_error($e->getMessage(), E_USER_ERROR); } } // Wrapper method for PDOStatement::fetchAll() public static function GetAll($sqlQuery, $params = null, $fetchStyle = PDO::FETCH_ASSOC) { // Initialize the return value to null $result = null; // Try to execute an SQL query or a stored procedure try { // Get the database handler $database_handler = self::GetHandler(); // Prepare the query for execution $statement_handler = $database_handler->prepare($sqlQuery); // Execute the query $statement_handler->execute($params); // Fetch result $result = $statement_handler->fetchAll($fetchStyle); } // Trigger an error if an exception was thrown when executing the SQL query catch(PDOException $e) { // Close the database handler and trigger an error self::Close(); LINE 89:trigger_error($e->getMessage(), E_USER_ERROR); } // Return the query results return $result; } // Wrapper method for PDOStatement::fetch() public static function GetRow($sqlQuery, $params = null, $fetchStyle = PDO::FETCH_ASSOC) { // Initialize the return value to null $result = null; // Try to execute an SQL query or a stored procedure try { // Get the database handler $database_handler = self::GetHandler(); // Prepare the query for execution $statement_handler = $database_handler->prepare($sqlQuery); // Execute the query $statement_handler->execute($params); // Fetch result $result = $statement_handler->fetch($fetchStyle); } // Trigger an error if an exception was thrown when executing the SQL query catch(PDOException $e) { // Close the database handler and trigger an error self::Close(); line 89 --trigger_error($e->getMessage(), E_USER_ERROR); } // Return the query results return $result; } // Return the first column value from a row public static function GetOne($sqlQuery, $params = null) { // Initialize the return value to null $result = null; // Try to execute an SQL query or a stored procedure try { // Get the database handler $database_handler = self::GetHandler(); // Prepare the query for execution $statement_handler = $database_handler->prepare($sqlQuery); // Execute the query $statement_handler->execute($params); // Fetch result $result = $statement_handler->fetch(PDO::FETCH_NUM); /* Save the first value of the result set (first column of the first row) to $result */ $result = $result[0]; } // Trigger an error if an exception was thrown when executing the SQL query catch(PDOException $e) { // Close the database handler and trigger an error self::Close(); trigger_error($e->getMessage(), E_USER_ERROR); } // Return the query results return $result; } } ?>


    ET J'AI CETTE ERREUR:




    ESKE KELKUN PEUT M'AIDER SVP!!!


    [sam] Modération: Utilise la balise code à l'avenir, merci
    • 3 replies
    • 2099 views