PDO ERROR TEXT: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while ot

Discussion in 'PHP' started by lau_jay84, Jun 24, 2010.

  1. #1
    HELLO EVERYBODY MY NAME IS LAURENT AND I M A PHP PROGRAMMING I JUST BEGIN IN USING PDO, WHILE I WAS WORKING ON A PROJECT HERE'S THE PAGE:

    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


    olympics high school


    forum wordpress themes french

    http://www.emilianbalanescu.ro/

    Smarty 2.6.18



    <?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;
    }
    }
    ?>




    AND I SUDDENLY GOT THIS ERROR MESSAGE

    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



    PLEASE CAN ANYBODY HELP ME HE WILL BE WELCOME.
     
    lau_jay84, Jun 24, 2010 IP