duanla8800 2016-05-03 14:39
浏览 76
已采纳

Kohana ORM find_all pk()函数在PHP 5.6.21中返回NULL

I have following code it was working fine for years but since I upgraded to PHP 5.6.21 its return NULL.

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

When I echo $result on server running PHP 5.6.20 row data from mysql is loaded in $_original_values, $_primary_key_value and $_changed is empty but in PHP 5.6.21 $_primary_key_value and $_original_values are empty and _changed has values of DB columns

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) 
  • 写回答

1条回答 默认 最新

  • douzhen1234 2016-05-06 21:59
    关注

    This issue was caused by a update in PHP 5.6.21, Its same behaviour in PHP 7.0.5 mysqli_fetch_object OR mysqli_result::fetch_object behaviour is change and its calling constructor before assigning values, So these values show up as changed values to a unloaded object in Kohana ORM.

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序 用oss下载 aliyun-oss-sdk-6.18.0.min client报错
  • ¥15 ArcGIS批量裁剪
  • ¥15 labview程序设计
  • ¥15 为什么在配置Linux系统的时候执行脚本总是出现E: Failed to fetch http:L/cn.archive.ubuntu.com
  • ¥15 Cloudreve保存用户组存储空间大小时报错
  • ¥15 伪标签为什么不能作为弱监督语义分割的结果?
  • ¥15 编一个判断一个区间范围内的数字的个位数的立方和是否等于其本身的程序在输入第1组数据后卡住了(语言-c语言)
  • ¥15 Mac版Fiddler Everywhere4.0.1提示强制更新
  • ¥15 android 集成sentry上报时报错。
  • ¥15 抖音看过的视频,缓存在哪个文件