我創建使用FuelPHP和ORM,文檔一個REST API這裏找到:http://fuelphp.com/docs/packages/orm/crud.html從ORM返回_data陣列FuelPHP
我可以返回數據庫行的對象,像這樣:
$entry = Model_V1_Inventory::find(1);
這會返回我PK等於1的對象,這與預期的一樣。如何訪問_data數組以將其作爲REST響應的一部分進行json_encode並將其返回?我可以簡單地調用訪問各個項目的數組中:
$entry->product_ref
作爲一個例子,但我不能看到返回它被保護_data數組的反正。
返回從ORM反對:
Model_V1_Inventory Object
(
[_is_new:protected] =>
[_frozen:protected] =>
[_sanitization_enabled:protected] =>
[_data:protected] => Array
(
[product_ref] => from the model
[cost_price] => 0.99
[rrp_price] => 11.67
[current_price] => 5.47
[description] => test description
[created_at] => 2016-04-26 14:29:20
[updated_at] => 2016-04-26 14:29:20
[id] => 1
)
[_custom_data:protected] => Array
(
)
[_original:protected] => Array
(
[product_ref] => from the model
[cost_price] => 0.99
[rrp_price] => 11.67
[current_price] => 5.47
[description] => test description
[created_at] => 2016-04-26 14:29:20
[updated_at] => 2016-04-26 14:29:20
[id] => 1
)
[_data_relations:protected] => Array
(
)
[_original_relations:protected] => Array
(
)
[_reset_relations:protected] => Array
(
)
[_disabled_events:protected] => Array
(
)
[_view:protected] =>
[_iterable:protected] => Array
(
)
)