I am new to using PDO and I think you're not caught exception due to errors in the query statements properly display the page output when it normally appears:
fatal error: message 'SQLSTATE [42000] with' exception exception 'PDOEception': ... I ask the PDO to use the following function:
/ ***************** ************* ********************************************************************* ***************** ***************************************************************************************************************************************** Create a PDF query * * Pre Position: The statement / query and an array of parameters containing the name (can be empty) must be passed. * Post Status: PDO query is executed. Exceptions are captured, displayed, and page execution stops. * * * * *********************************************************************************************** **************************************************************************************************** **************************************************************************************************** ********** / function makeQuery ($ stmt, $ array, $ errMsg = '') {try {$ stmt- & gt; Execute ($ array); } Hold (PDOException $ E) {print $ errMsg = '' $ errMsg:!? "Error !:". $ E- & gt; Received Message () "
"; Die (); Any thoughts are not going to catch an exception? Edit: This makes way I PDO object like:
Create function PDO () {// MySQL connection details $ dbhost = ''; $ Dbuser = ''; $ Dbpass = ''; $ Dbname = ''; Try {$ db = new PDO ( "mysql: $ dbhost = localhost; dbname = $ dbname; charset = UTF8", $ dbuser, $ dbpass, array (PDO :: ATTR_EMULATE_PREPARES = & gt; false, PDO :: ATTR_ERRMODE = & Gt; PDO :: ERRMODE_EXCEPTION); } Hold (PDOException $ e) {Print "Error !:" $ E- & gt; Received Message () "
"; Die (); } Return $ db; }
Are you sure every query through that The function is going on? One can have 100% something to look through in your code Another option is to simply define which exception is a global exception handler to ask. The file came from:
function exception_handler ($ exception) {echo "unspecified exception:". $ Exception-> Received message () PHP_EOL; Resonant "in the file:" $ Exception-> GetFile () PHP_EOL; "Echo on Line": $ Exception-> Milan () PHP_EOL; } Set_exception_handler ('exception_handler'); In : yet function as a casing can communicate w / o P i is now certain that the call to PDOStatement :: I'm ready after which throw exceptions being, so I'm recommending library:
function prepareStmt (PDO $ oPdo, $ sStmt, array $ aDriverOptions = array ()) {try {return $ oPdo- & gt ; Ready ($ sStmt, $ aDriverOptions); } Hold (PDOException $ E) {Print "Error !:" $ E- & gt; Received Message () "
"; Die (); }}
Comments
Post a Comment