我有一个描述数据库表及其关系的数组。
假设我们有一个products
表,其中包含以下字段:
并根据表格创建一个带有详细信息的对象。
Array
(
[pk] => product_id
[Fields] => Array
(
[column1] => stdClass Object
(
[Position] => 1
[Label] => Column1
)
[column2] => stdClass Object
(
[Position] => 3
[Label] => Column2
)
[column_three] => stdClass Object
(
[Position] => 4
[Label] => Column Three
)
//and here are the relations
[Relations] => Array
(
//the field category_name from category model
[category_name] => stdClass Object
(
[Position] => 2
[Label] => Category Name
[Model] => category
[Relation] => belongs_to
[PK] => id_categorie
)
[image_name] => stdClass Object
(
[Position] => 5
[Label] => Image Name
[Model] => image
[Relation] => has_one
[PK] => image_id
[Through] => product_id
)
)
如何在视图中循环此数组,以便我可以使用标签创建一个表格,其中包含按位置排序的以下内容?
Column1
Category Name
Column2
Column Three
Image Name