An Idea to Improve for FX.php

更新
Masayuki Nii/msyk@msyk.net

The following result is one of typical result from querying by FX.php. As the FileMaker server response is not fully informative, the last [0] index requires not only repeating or portal fields but also single value fields. We are already familiar with it but I wonder how new comers think about.

Array
(
    [1.2] => Array
        (
            [id] => Array
                (
                    [0] => 1
                )

            [name] => Array
                (
                    [0] => Sevens Door’s FileMaker Fun Night
                )

            [Admin_Items::kind] => Array
                (
                    [0] => 1
                    [1] => 2
                    [2] => 3
                    [3] => 4
                )

            [Admin_Items::title] => Array
                (
                    [0] => これが予定です。
                    [1] => 面白ければ拍手
                    [2] => 登録してください
                    [3] => アンケートに答えてね
                )

            [Admin_ClientAnswer::clientID] => Array
                (
                )

            [Admin_ClientAnswer::ts] => Array
                (
                )
        )
)

The FlattenInnerArray function can change the format of the response and it doesn't require to add [0]. Although it returns just single value in spite of it's repeating/portal field.

Array
(
    [1.2] => Array
        (
            [id] => 1
            [name] => Sevens Door’s FileMaker Fun Night
            [Admin_Items::kind] => 4
            [Admin_Items::title] => アンケートに答えてね
        )

)

The ideal results are the following two examples. Single field returns single value with string, and portal/repeating field returns by array. The later one returns whole portal results as array. I think it's so redundant including a portal name both the portal and field names, but it's not relevant. It comes from the response of FileMaker Server.

Array
(
    [1.2] => Array
        (
            [id] =>  1
            [name] => Sevens Door’s FileMaker Fun Night
            [Admin_Items::kind] => Array
                (
                    [0] => 1
                    [1] => 2
                    [2] => 3
                    [3] => 4
                )

            [Admin_Items::title] => Array
                (
                    [0] => これが予定です。
                    [1] => 面白ければ拍手
                    [2] => 登録してください
                    [3] => アンケートに答えてね
                )

            [Admin_ClientAnswer::clientID] => Array
                (
                )

            [Admin_ClientAnswer::ts] => Array
                (
                )
        )
)
Array
(
    [1.2] => Array
        (
            [id] =>  1
            [name] => Sevens Door’s FileMaker Fun Night
            [Admin_Items] => Array
                (
                    [0] => Array
                         (
                               [Admin_Items::kind] => 1
                               [Admin_Items::title] => これが予定です。
                         )
                    [1] =>  Array
                         (
                               [Admin_Items::kind] => 2
                               [Admin_Items::title] => 面白ければ拍手
                         )
                    [2] =>  Array
                         (
                               [Admin_Items::kind] => 3
                               [Admin_Items::title] => 登録してください
                         )
                    [3] =>  Array
                         (
                               [Admin_Items::kind] => 4
                               [Admin_Items::title] => アンケートに答えてね
                         )
                )

            [Admin_ClientAnswer] => Array
                (
                )
        )
)

I thought how to realize above responses, and watch the source of FX.php. So my idea is adding the RemainAsArray function as below. I know it's not perfect solution but a little bit advance from now. If one filed in a portal is using out side of the portal, its single field will return array and requires [0] to get the value.

$fx = new FX(....);
$fx->FlattenInnerArray();
$fx->RemainAsArray( "Admin_Items", "Admin_ClientAnswer" );
	or
$fx->RemainAsArray( array( "Admin_Items" ), array( "Admin_ClientAnswer" ));

Additionally the implementation could be done as following. Maybe ten parameters will be enough.

function RemainAsArray( param1, param2 = "",param3 = "",param4 = "",param5 = "" )	{ }

How do you think about it? If you need or support my idea, I could implement this feature.