【问题标题】:Kohana ORM find_all pk() function return NULL in PHP 5.6.21Kohana ORM find_all pk() 函数在 PHP 5.6.21 中返回 NULL
【发布时间】:2016-05-03 14:39:07
【问题描述】:

我有以下代码多年来一直运行良好,但自从我升级到 PHP 5.6.21 后它返回 NULL。

$model = new Model_Status ();
$results = $model->find_all ();
foreach ( $results as $result ) {
   echo $result->pk ();
}

当我在运行 PHP 5.6.20 的服务器上回显 $result 时,来自 mysql 的行数据加载到 $_original_values 中,$_primary_key_value 和 $_changed 为空,但在 PHP 5.6.21 中 $_primary_key_value 和 $_original_values 为空,_changed 的​​值为数据库列

echo Debug::vars($result)
//php 5.6.20
    protected _object => array(6) (
            "id" => string(1) "1"
            "name" => string(4) "Live"
            "code" => string(3) "401"
            "message" => string(12) "site is live"
            "created" => NULL
            "modified" => NULL
        )
        protected _changed => array(0) 
        protected _original_values => array(6) (
            "id" => string(1) "1"
            "name" => string(4) "Live"
            "code" => string(3) "401"
            "message" => string(12) "site is live"
            "created" => NULL
            "modified" => NULL
        )
//php 5.6.21
    protected _object => array(6) (
            "id" => string(1) "1"
            "name" => string(4) "Live"
            "code" => string(3) "401"
            "message" => string(12) "site is live"
            "created" => NULL
            "modified" => NULL
        )
        protected _changed =>  array(4) (
            "id" => string(2) "id"
            "name" => string(4) "name"
            "code" => string(2) "code"
            "message" => string(7) "message"
        )
        protected _original_values => array(0) 

【问题讨论】:

    标签: php kohana php-5.6 kohana-orm


    【解决方案1】:

    这个问题是由 PHP 5.6.21 中的更新引起的,它在 PHP 7.0.5 中的行为相同 mysqli_fetch_objectmysqli_result::fetch_object 行为是在分配值之前更改及其调用构造函数,因此这些值在 Kohana ORM 中显示为已卸载对象的更改值。

    Here is link of Kohana ORM issue Here is link to PHP bug report

    【讨论】:

      猜你喜欢
      • 2011-05-02
      • 2011-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-15
      • 2017-11-28
      相关资源
      最近更新 更多