internals2.pdo.error-handling.html

来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 70 行

HTML
70
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Error handling</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="internals2.pdo.html">PDO Driver How-To</a></div> <div class="next" style="text-align: right; float: right;"><a href="internals2.faq.html">Extension FAQs</a></div> <div class="up"><a href="internals2.pdo.html">PDO Driver How-To</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="internals2.pdo.error-handling" class="sect1"> <h2 class="title">Error handling</h2> <p class="para">  Error handling is implemented using a hand-shaking protocol between   PDO and the database driver code. The database driver code  signals PDO that an error has occurred via a failure  (<i>0</i>) return from any of the interface functions. If a zero  is returned, set the field <i><tt class="parameter">error_code</tt></i> in the control  block appropriate to the context (either the pdo_dbh_t or pdo_stmt_t block).  In practice, it is probably a good idea to set the field in both blocks to  the same value to ensure the correct one is getting used. </p> <p class="para">  The error_mode field is a six-byte field containing a 5 character ASCIIZ  SQLSTATE identifier code. This code drives the error message process. The  SQLSTATE code is used to look up an error message in the internal PDO error  message table (see pdo_sqlstate.c for a list of error codes and their  messages). If the code is not known to PDO, a default  "<span class="quote">Unknown Message</span>" value will be used. </p> <p class="para">  In addition to the SQLSTATE code and error message, PDO will  call the driver-specific fetch_err() routine to obtain supplemental data  for the particular error condition. This routine is passed an array into  which the driver may place additional information. This array has slot  positions assigned to particular types of supplemental info: </p> <ol class="orderedlist">  <li class="listitem">   <p class="para">    A native error code. This will frequently be an error code obtained    from the database API.   </p>  </li>  <li class="listitem">   <p class="para">    A descriptive string. This string can contain any additional    information related to the failure. Database drivers typically include    information such as an error message, code location of the failure, and    any additional descriptive information the driver developer feels    worthy of inclusion. It is generally a good idea to include all    diagnostic information obtainable    from the database interface at the time of the failure. For    driver-detected errors (such as memory allocation problems), the driver    developer can define whatever error information that seems appropriate.   </p>  </li> </ol></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="internals2.pdo.html">PDO Driver How-To</a></div> <div class="next" style="text-align: right; float: right;"><a href="internals2.faq.html">Extension FAQs</a></div> <div class="up"><a href="internals2.pdo.html">PDO Driver How-To</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?