• <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()

        Doctrine 2: Call to a member function format() on a non-object ... in DateTimeType.php(原则 2:在 DateTimeType.php 中对非对象 ... 调用成员函数 format())

            • <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()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  When should use doctrine ORM and when zend-db-table?(什么时候应该使用学说 ORM,什么时候应该使用 zend-db-table?)
                  Doctrine - self-referencing entity - disable fetching of children(Doctrine - 自引用实体 - 禁用获取子项)
                  Doctrine 2, query inside entities(原则 2,实体内部查询)
                  Complex WHERE clauses using the PHP Doctrine ORM(使用 PHP Doctrine ORM 的复杂 WHERE 子句)
                  Doctrine - OneToMany relation, all result row doesn#39;t fetch in object(Doctrine - OneToMany 关系,所有结果行不获取对象)
                  Doctrine and unrefreshed relationships(教义和未更新的关系)
                1. <legend id='bEOIq'><style id='bEOIq'><dir id='bEOIq'><q id='bEOIq'></q></dir></style></legend>

                    • <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>
                      • <tfoot id='bEOIq'></tfoot>

                            <tbody id='bEOIq'></tbody>

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