1. <i id='EwRrM'><tr id='EwRrM'><dt id='EwRrM'><q id='EwRrM'><span id='EwRrM'><b id='EwRrM'><form id='EwRrM'><ins id='EwRrM'></ins><ul id='EwRrM'></ul><sub id='EwRrM'></sub></form><legend id='EwRrM'></legend><bdo id='EwRrM'><pre id='EwRrM'><center id='EwRrM'></center></pre></bdo></b><th id='EwRrM'></th></span></q></dt></tr></i><div id='EwRrM'><tfoot id='EwRrM'></tfoot><dl id='EwRrM'><fieldset id='EwRrM'></fieldset></dl></div>
      <tfoot id='EwRrM'></tfoot>
        <bdo id='EwRrM'></bdo><ul id='EwRrM'></ul>
      <legend id='EwRrM'><style id='EwRrM'><dir id='EwRrM'><q id='EwRrM'></q></dir></style></legend>

    2. <small id='EwRrM'></small><noframes id='EwRrM'>

        PHP PDO:获取样式 FETCH_CLASS 和 FETCH_INTO 是否获取到

        时间:2023-10-04

        1. <small id='NVYuS'></small><noframes id='NVYuS'>

          <tfoot id='NVYuS'></tfoot>
          <legend id='NVYuS'><style id='NVYuS'><dir id='NVYuS'><q id='NVYuS'></q></dir></style></legend>

            <tbody id='NVYuS'></tbody>
            • <bdo id='NVYuS'></bdo><ul id='NVYuS'></ul>

                <i id='NVYuS'><tr id='NVYuS'><dt id='NVYuS'><q id='NVYuS'><span id='NVYuS'><b id='NVYuS'><form id='NVYuS'><ins id='NVYuS'></ins><ul id='NVYuS'></ul><sub id='NVYuS'></sub></form><legend id='NVYuS'></legend><bdo id='NVYuS'><pre id='NVYuS'><center id='NVYuS'></center></pre></bdo></b><th id='NVYuS'></th></span></q></dt></tr></i><div id='NVYuS'><tfoot id='NVYuS'></tfoot><dl id='NVYuS'><fieldset id='NVYuS'></fieldset></dl></div>

                • 本文介绍了PHP PDO:获取样式 FETCH_CLASS 和 FETCH_INTO 是否获取到私有对象属性中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  很短的问题,这是一个例子:

                  Pretty short question, here is an example:

                  $prepared = $this->pdo->prepare("SELECT * FROM Users WHERE ID = :ID");
                  $statement = $prepared->execute(array(":ID" => $User_ID))
                  $result = $statement->fetchAll(PDO::FETCH_CLASS, "User");
                  //OR
                  $User = new User();
                  $result = $statement->fetch(PDO::FETCH_INTO, $User);
                  

                  (从头开始写,可能包含语法错误)

                  (written from top of the head, could contain syntax errors)

                  这两个是否直接获取到所述对象的私有属性?我读到它也绕过了 __construct 函数,那么它也会绕过私有状态吗?

                  Do those two directly fetch into the private properties of said objects? I read it also circumvents the __construct function, so will it circumvent private status too?

                  推荐答案

                  非常简短的回答:是的.

                  Very short answer: Yes it will.

                  class Foo
                  {
                      private $id;
                      public function echoID()
                      {
                          echo $this->id;
                      }
                  }
                  $result = $statement->fetchAll(PDO::FETCH_CLASS, "Foo");
                  $result[0]->echoID(); // your ID
                  

                  <小时>

                  旁白:

                  这会导致语法错误$statement->fetchAll(PDO::FETCH_INTO, $User);.您不能将 FETCH_INTOfetchAll 方法一起使用.

                  This will cause syntax errors $statement->fetchAll(PDO::FETCH_INTO, $User);. You can't use FETCH_INTO with the fetchAll method.

                  这篇关于PHP PDO:获取样式 FETCH_CLASS 和 FETCH_INTO 是否获取到私有对象属性中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:无法使用 PHP 连接到 SQL Server 下一篇:nd_pdo_mysql 和 pdo_mysql 扩展之间有什么区别?

                  相关文章

                  最新文章

                  <small id='Q8rox'></small><noframes id='Q8rox'>

                • <legend id='Q8rox'><style id='Q8rox'><dir id='Q8rox'><q id='Q8rox'></q></dir></style></legend>
                • <i id='Q8rox'><tr id='Q8rox'><dt id='Q8rox'><q id='Q8rox'><span id='Q8rox'><b id='Q8rox'><form id='Q8rox'><ins id='Q8rox'></ins><ul id='Q8rox'></ul><sub id='Q8rox'></sub></form><legend id='Q8rox'></legend><bdo id='Q8rox'><pre id='Q8rox'><center id='Q8rox'></center></pre></bdo></b><th id='Q8rox'></th></span></q></dt></tr></i><div id='Q8rox'><tfoot id='Q8rox'></tfoot><dl id='Q8rox'><fieldset id='Q8rox'></fieldset></dl></div>
                        <bdo id='Q8rox'></bdo><ul id='Q8rox'></ul>

                      <tfoot id='Q8rox'></tfoot>