Illuminate を使用してデータベースにアクセスしています
<body>
<?php
$edges = Edge::all();
foreach ($edges as $key => $value) {
print $value;
}
?>
</body>
ブラウザの戻り値:
{"childID":"A","parentID":"C","updated_at":null,"created_at":null}{"childID":"B","parentID":"E","updated_at":null,"created_at":null}{"childID":"C","parentID":"D","updated_at":null,"created_at":null}{"childID":"C","parentID":"F","updated_at":null,"created_at":null}{"childID":"Y","parentID":"Z","updated_at":"2014-08-07 10:26:54","created_at":"2014-08-07 10:26:54"}
少なくとも私にとって奇妙または予期しないことは、結果が JSON で返されることです。これに光を当てることができれば、つまり、これがなぜなのか、またはその理由は...感謝しています。
結果をブラウザーにダンプすると、次のようになります。
<?php
print '<pre>';print_r($edges);
?>
生成:
Illuminate\Database\Eloquent\Collection Object
(
[items:protected] => Array
(
[0] => Edge Object
(
[connection:protected] =>
[table:protected] =>
[primaryKey:protected] => id
[perPage:protected] => 15
[incrementing] => 1
[timestamps] => 1
[attributes:protected] => Array
(
[childID] => A
[parentID] => C
[updated_at] =>
[created_at] =>
)
[original:protected] => Array
(
[childID] => A
[parentID] => C
[updated_at] =>
[created_at] =>
)
[relations:protected] => Array
(
)
[hidden:protected] => Array
(
)
[visible:protected] => Array
(
)
[appends:protected] => Array
(
)
[fillable:protected] => Array
(
)
[guarded:protected] => Array
(
[0] => *
)
[dates:protected] => Array
(
)
[touches:protected] => Array
(
)
[observables:protected] => Array
(
)
[with:protected] => Array
(
)
[morphClass:protected] =>
[exists] => 1
)
[1] => Edge Object
(...)
...
)
フロントエンドの結果に関しては、私が本当に興味があるのは次のことだけです。
[childID] => A
[parentID] => C
[updated_at] =>
[created_at] =>
オブジェクトの一部。JSON のみではありません。平文で。