• <tfoot id='nDG9M'></tfoot>

  • <small id='nDG9M'></small><noframes id='nDG9M'>

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

        原则 2:在 DateTimeType.php 中对非对象 ... 调用成员函数 format()

        时间:2024-08-10

            • <bdo id='N2VX2'></bdo><ul id='N2VX2'></ul>
              <legend id='N2VX2'><style id='N2VX2'><dir id='N2VX2'><q id='N2VX2'></q></dir></style></legend>

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

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

                  <tfoot id='N2VX2'></tfoot>
                  本文介绍了原则 2:在 DateTimeType.php 中对非对象 ... 调用成员函数 format()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 DateTime 字段:

                  /**
                   * Date time posted
                   * @Column(type="datetime")
                   */
                  private $dtPosted;
                  

                  使用 LifeCycleCallback 设置为默认值

                  which is set to a default value by using a LifeCycleCallback

                  /**
                   * @PrePersist
                   */
                  function onPrePersist() {
                      // set default date
                      $this->dtPosted = date('Y-m-d H:m:s');
                  

                  我收到以下错误:

                  致命错误:调用成员函数format() 在非对象上D:ResourceLibraryFrameworksDoctrinelibDoctrineDBALTypesDateTimeType.php第 46 行

                  Fatal error: Call to a member function format() on a non-object in D:ResourceLibraryFrameworksDoctrinelibDoctrineDBALTypesDateTimeType.php on line 46

                  推荐答案

                  date() 函数返回一个字符串.datetime 类型适用于 DateTime 对象.因此,要么将映射类型更改为 string,要么使用 DateTime 对象.

                  The date() function returns a string. The datetime type works with DateTime objects. So either change the mapping type to string or use DateTime objects.

                  这篇关于原则 2:在 DateTimeType.php 中对非对象 ... 调用成员函数 format()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:MYSQL DATETIME 格式不正确 下一篇:Doctrine 2 如何在不调用实体构造函数的情况下检索实体?

                  相关文章

                1. <legend id='bEOIq'><style id='bEOIq'><dir id='bEOIq'><q id='bEOIq'></q></dir></style></legend>

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

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

                        <bdo id='bEOIq'></bdo><ul id='bEOIq'></ul>