IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

erreur PD0 2014


Sujet :

PHP & Base de données

  1. #1
    Nouveau Candidat au Club
    Inscrit en
    Juin 2010
    Messages
    1
    Détails du profil
    Informations forums :
    Inscription : Juin 2010
    Messages : 1
    Points : 1
    Points
    1
    Par défaut erreur PD0 2014
    Bonjour, voici mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
     
    <?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'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:
    ERRNO: 256
    TEXT: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.
    LOCATION: C:\tshirtshop\business\database_handler.php, line 89, at June 23, 2010, 10:16 am
    Showing backtrace:
    trigger_error("SQLSTATE[HY000]: General error: 2014 Cannot execute queries whil...", "256") # line 89, file: C:\tshirtshop\business\database_handler.php
    DatabaseHandler.GetAll("CALL catalog_get_departments_list()") # line 11, file: C:\tshirtshop\business\catalog.php
    Catalog.GetDepartments() # line 21, file: C:\tshirtshop\presentation\departments_list.php
    DepartmentsList.init() # line 13, file: C:\tshirtshop\presentation\smarty_plugins\function.load_presentation_object.php
    smarty_function_load_presentation_object(Array[2], Object: Application) # line 5, file: C:\tshirtshop\presentation\templates_c\%%A5^A5A^A5A1C73D%%departments_list.tpl.php
    include("C:\tshirtshop\presentation\templates_c\%%A5^A5A^A5A1C73D%%depart...") # line 1869, file: C:\tshirtshop\libs\smarty\Smarty.class.php
    Smarty._smarty_include(Array[2]) # line 46, file: C:\tshirtshop\presentation\templates_c\%%41^412^412F4E3D%%store_front.tpl.php
    include("C:\tshirtshop\presentation\templates_c\%%41^412^412F4E3D%%store_...") # line 1256, file: C:\tshirtshop\libs\smarty\Smarty.class.php
    Smarty.fetch("store_front.tpl", null, null, true) # line 1106, file: C:\tshirtshop\libs\smarty\Smarty.class.php
    Smarty.display("store_front.tpl") # line 26, file: C:\tshirtshop\index.php

    Pourriez-vous m'aider ?

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Essaie ce qui est indiqué dans l'erreur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    self::$_mHandler->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Invité
    Invité(e)
    Par défaut
    Bonsoir,
    Plusieurs remarques, je croyais que PDO travaillais mal ,quand on l'enfermait dans d'autres class , bon pas certaine, mais a voir. )

    Autre point c'est le premier message qui me fait tiquer, en effet tu semblerais étre justement dans le cas ou closecursor est obligatoir lorsqu'une requéte est encore active.

    C'est trés bien expliqué ici
    http://php.net/manual/fr/pdostatement.closecursor.php

    Et précisément (a mon avis ) a cause de ce que j'ais dis sur les class imbriquées.

Discussions similaires

  1. PhpMyAdmin erreur 2014 au login
    Par bankette dans le forum Administration
    Réponses: 2
    Dernier message: 19/08/2010, 09h36
  2. [MySql][D6 Perso] Erreur "2014 Commands out of sync;&qu
    Par Caine dans le forum Bases de données
    Réponses: 1
    Dernier message: 09/03/2006, 08h32

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo