internals2.pdo.pdo-dbh-t.html

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

HTML
189
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>pdo_dbh_t definition</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.packaging.html">Packaging and distribution</a></div> <div class="next" style="text-align: right; float: right;"><a href="internals2.pdo.pdo_stmt_t.html">pdo_stmt_t definition</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.pdo-dbh-t" class="sect1"> <h2 class="title">pdo_dbh_t definition</h2> <p class="para">  All fields should be treated as read-only by the driver, unless explicitly  stated otherwise. </p> <div class="figure">  <h1 class="title">pdo_dbh_t</h1>  <div class="example-contents"><div class="cdata"><pre>/* represents a connection to a database */struct _pdo_dbh_t {    /* driver specific methods */    struct pdo_dbh_methods *methods;    </pre></div><a name="internals2.pdo.dbh.co.methods" id="internals2.pdo.dbh.co.methods">*</a><div class="cdata"><pre>    /* driver specific data */    void *driver_data;                  </pre></div><a name="internals2.pdo.dbh.co.driver-data" id="internals2.pdo.dbh.co.driver-data">**</a><div class="cdata"><pre>    /* credentials */    char *username, *password;          </pre></div><a name="internals2.pdo.dbh.co.credentials" id="internals2.pdo.dbh.co.credentials">***</a><div class="cdata"><pre>    /* if true, then data stored and pointed at by this handle must all be     * persistently allocated */    unsigned is_persistent:1;           </pre></div><a name="internals2.pdo.dbh.co.is-persist" id="internals2.pdo.dbh.co.is-persist">****</a><div class="cdata"><pre>    /* if true, driver should act as though a COMMIT were executed between     * each executed statement; otherwise, COMMIT must be carried out manually     * */    unsigned auto_commit:1;             </pre></div><a name="internals2.pdo.dbh.co.auto-commit" id="internals2.pdo.dbh.co.auto-commit">*****</a><div class="cdata"><pre>    /* if true, the driver requires that memory be allocated explicitly for     * the columns that are returned */    unsigned alloc_own_columns:1;       </pre></div><a name="internals2.pdo.dbh.co.alloc-own" id="internals2.pdo.dbh.co.alloc-own">******</a><div class="cdata"><pre>    /* if true, commit or rollBack is allowed to be called */    unsigned in_txn:1;                      /* max length a single character can become after correct quoting */    unsigned max_escaped_char_length:3;   </pre></div><a name="internals2.pdo.dbh.co.max-esc" id="internals2.pdo.dbh.co.max-esc">*******</a><div class="cdata"><pre>    /* data source string used to open this handle */    const char *data_source;            </pre></div><a name="internals2.pdo.dbh.co.dsn" id="internals2.pdo.dbh.co.dsn">********</a><div class="cdata"><pre>    unsigned long data_source_len;    /* the global error code. */    pdo_error_type error_code;          </pre></div><a name="internals2.pdo.dbh.co.error-code" id="internals2.pdo.dbh.co.error-code">*********</a><div class="cdata"><pre>    enum pdo_case_conversion native_case</pre></div><a name="internals2.pdo.dbh.co-ncase" id="internals2.pdo.dbh.co-ncase">**********</a><div class="cdata"><pre>, desired_case;};  </pre></div></div> </div> <table>  <tr><td><a href="#internals2.pdo.dbh.co.methods">*</a></td><td>   <p class="para">    The driver <em class="emphasis">must</em> set this during    <b>SKEL_handle_factory()</b>.   </p>  </td></tr>  <tr><td><a href="#internals2.pdo.dbh.co.driver-data">**</a></td><td>   <p class="para">    This item is for use by the driver; the intended usage is to store a    pointer (during <b>SKEL_handle_factory()</b>)     to whatever instance data is required to maintain a connection to    the database.   </p>  </td></tr>  <tr><td><a href="#internals2.pdo.dbh.co.credentials">***</a></td><td>   <p class="para">    The username and password that were passed into the PDO constructor.    The driver should use these values when it initiates a connection to the    database.   </p>  </td></tr>  <tr><td><a href="#internals2.pdo.dbh.co.is-persist">****</a></td><td>   <p class="para">    If this is set to 1, then any data that is referenced by the    dbh, including whatever structure your driver allocates,    <em class="emphasis">MUST</em> be allocated persistently.  This is easy to    achieve; rather than using the usual <b>emalloc()</b> simply    use <b>pemalloc()</b> and pass the value of this flag as the    last parameter.  Failure to use the appropriate kind of memory can lead    to serious memory faults, resulting (in the best case) a hard crash, and    in the worst case, an exploitable memory problem.   </p>   <p class="para">    If, for whatever reason, your driver is not suitable to run persistently,    you <em class="emphasis">MUST</em> check this flag in your    <b>SKEL_handle_factory()</b> and raise an appropriate error.   </p>  </td></tr>  <tr><td><a href="#internals2.pdo.dbh.co.auto-commit">*****</a></td><td>   <p class="para">    You should check this value in your <b>SKEL_handle_doer()</b>    and <b>SKEL_stmt_execute()</b> functions; if it evaluates to    true, you must attempt to commit the query now.  Most database    implementations offer an auto-commit mode that handles this automatically.   </p>  </td></tr>  <tr><td><a href="#internals2.pdo.dbh.co.alloc-own">******</a></td><td>   <p class="para">    If your database client library API operates by fetching data into a    caller-supplied buffer, you should set this flag to 1 during your    <b>SKEL_handle_factory()</b>.  When set, PDO will call your    <b>SKEL_stmt_describer()</b> earlier than it would    otherwise.  This early call allows you to determine those buffer sizes    and issue appropriate calls to the database client library.   </p>   <p class="para">    If your database client library API simply returns pointers to its own    internal buffers for you to copy after each fetch call, you should leave    this value set to 0.   </p>  </td></tr>  <tr><td><a href="#internals2.pdo.dbh.co.max-esc">*******</a></td><td>   <p class="para">    If your driver doesn&#039;t support native prepared statements    (<i><tt class="parameter">supports_placeholders</tt></i> is set to    <b><tt>PDO_PLACEHOLDER_NONE</tt></b>), you must set    this value to the maximum length that can be taken up by a single    character when it is quoted by your    <b>SKEL_handle_quoter()</b> function.  This value is used to    calculate the amount of buffer space required when PDO executes the    statement.   </p>  </td></tr>  <tr><td><a href="#internals2.pdo.dbh.co.dsn">********</a></td><td>   <p class="para">    This holds the value of the DSN that was passed into the PDO    constructor.  If your driver implementation needed to modify the DSN for    whatever reason, it should update this member during    <b>SKEL_handle_factory()</b>.  Modifying this member should    be avoided.  If you do change it, you must ensure that    <i><tt class="parameter">data_source_len</tt></i> is also correct.   </p>  </td></tr>  <tr><td><a href="#internals2.pdo.dbh.co.error-code">*********</a></td><td>   <p class="para">    Whenever an error occurs during a call to one of your driver methods,    you should set this member to the SQLSTATE code that best describes the    error and return an error.  In this HOW-TO, the suggested practice is to    call <b>SKEL_handle_error()</b> when an error is detected,    and have it set the error code.   </p>  </td></tr>  <tr><td><a href="#internals2.pdo.dbh.co-ncase">**********</a></td><td>   <p class="para">    Your driver should set this during    <b>SKEL_handle_factory()</b>; the value should reflect how    the database returns the names of the columns in result sets.  If the    name matches the case that was used in the query, set it to    <b><tt>PDO_CASE_NATURAL</tt></b> (this is actually the default).    If the column names are always returned in upper case, set it to    <b><tt>PDO_CASE_UPPER</tt></b>.  If the column names are always    returned in lower case, set it to <b><tt>PDO_CASE_LOWER</tt></b>.    The value you set is used to determine if PDO should perform case    folding when the user sets the <b><tt>PDO_ATTR_CASE</tt></b>    attribute.   </p>  </td></tr> </table></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="internals2.pdo.packaging.html">Packaging and distribution</a></div> <div class="next" style="text-align: right; float: right;"><a href="internals2.pdo.pdo_stmt_t.html">pdo_stmt_t definition</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 + -
显示快捷键?