我有以下代码,它运行良好多年,但自从我升级到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)
答案 0 :(得分:0)
此问题是由PHP 5.6.21中的更新引起的,其在PHP 7.0.5中的行为相同
mysqli_fetch_object
OR mysqli_result::fetch_object
行为在分配值之前是更改及其调用构造函数,因此这些值在Kohana ORM中显示为已更改的值到已卸载的对象。
Here is link of Kohana ORM issue Here is link to PHP bug report