获取对象的字段数据
fixed Module_OOP_ORM_Parse::get_object_field_data( fixed $obj [, string $callback_fun = null ] )
参数列表
参数 类型 描述 默认值 $obj
fixed
$obj $callback_fun
string
$callback_fun null
fixed
返回字段数据public static function get_object_field_data($obj, $callback_fun = null)
{
if ( $callback_fun )
{
$data = $obj->$callback_fun();
}
elseif ( $obj instanceof OOP_ORM_Data )
{
$data = $obj->get_field_data();
}
elseif ( $obj instanceof stdClass )
{
$data = (array)$obj;
}
elseif ( $obj instanceof OOP_ORM )
{
# OOP_ORM对象无法作用于实际数据
return false;
}
elseif ( method_exists($obj, 'getArrayCopy') )
{
$data = $obj->getArrayCopy();
}
elseif ( method_exists($obj, '__toString') )
{
$data = $obj->__toString();
}
else
{
# 对于未知且没有设置回调方法的对象,返回get_object_vars()结果
return get_object_vars($obj);
}
return $data;
}