[FX.php List] Get portals as array

Masayuki Nii msyk at msyk.net
Sat Dec 18 01:46:32 MST 2010


Hi everyone,

I've implemented new method RemainAsArray and committed to SF.net as Revision 
9. I've posted my conclusion as a preliminary to "http://msyk.net/fmp/fx_ja/
trial.html."

I will explain how to work the method, suppose the following a simple layout 
and fields. The starting "-" line means one field.

========================In Layout
Fields out side of portal:
- name
- telephone

Portal: contact_list
- contact_list::date
- contact_list::person

Portal: payment_list
- payment_list::date
- payment_list::price
========================In Layout

You call the FlattenInnerArray method and the RemainAsArray method as following. 
If you set the 3rd parameter of DoFxAction method, You don't need to call the 
FlattenInnerArray method. As for the RemainAsArray method, you should write 
the portal name (i.e. TOC name) as  parameters. You can specify from 1 to 12 
parameters, and at least one, but you can increase up to 12.

$fx = new FX('127.0.0.1', '80', 'FMPro7', 'HTTP');
.... set various parameters ....
$fx->FlattenInnerArray();// This is same effect for 3rd paramter of DoFxAction
$fx->RemainAsArray( 'payment_list', 'contact_list' );
$result = $fx->DoFxAction( FX_ACTION_FIND, TRUE, FALSE, 'full' );

I will a sample of the contents of $result variable below. You don't need to 
specify the [0] after ["name"]. Otherwise the field in the portal will be retrieve 
as like without calling the FlattenInnerArray method. You need numeric index 
after portal field ["contact_list::date"].

array(YY)	{
	["data"]=>
	array(XX)	{
		["1.5"]=>
		array(6)	{
			['name']=>
			string(NN) "string string"
			['telephone']=>
			string(NN) "string string"
			['contact_list::date']=>
			array(2)	{
				[0]=>
				string(N) "string string"
				[1]=>
				string(N) "string string"
			}
			['contact_list::person']=>
			array(2)	{
				[0]=>
				string(N) "string string"
				[1]=>
				string(N) "string string"
			}
			['payment_list::date']=>
			array(3)	{
				[0]=>
				string(N) "string string"
				[1]=>
				string(N) "string string"
				[2]=>
				string(N) "string string"
			}
			['payment_list::price']=>
			array(3)	{
				[0]=>
				string(N) "string string"
				[1]=>
				string(N) "string string"
				[2]=>
				string(N) "string string"
			}
		}
	:
	:


Furthermore, the RemainAsArray method can affect with different result. If the 
parameter of the RemainAsArray function is array, the portal will expand to 
array. At least one parameter is array, it will affect all portal results.

$fx = new FX('127.0.0.1', '80', 'FMPro7', 'HTTP');
.... set various parameters ....
$fx->FlattenInnerArray();// This is same effect for 3rd paramter of DoFxAction
$fx->RemainAsArray( array('payment_list'), array('contact_list') );
$result = $fx->DoFxAction( FX_ACTION_FIND, TRUE, FALSE, 'full' );

This is a sample result.

array(YY)	{
	["data"]=>
	array(XX)	{
		["1.5"]=>
		array(4)	{
			['name']=>
			string(NN) "string string"
			['telephone']=>
			string(NN) "string string"
			['contact_list]=>
			array(2)	{
				[0]=>
				array(2)	{
					["contact_list::date"]=>
					string(N) "string string"
					["contact_list::person"]=>
					string(N) "string string"
				}
				[1]=>
				array(2)	{
					["contact_list::date"]=>
					string(N) "string string"
					["contact_list::person"]=>
					string(N) "string string"
				}
			}
			['payment_list]=>
			array(3)	{
				[0]=>
				array(2)	{
					["payment_list::date"]=>
					string(N) "string string"
					["payment_list::price"]=>
					string(N) "string string"
				}
				[1]=>
				array(2)	{
					["payment_list::date"]=>
					string(N) "string string"
					["payment_list::price"]=>
					string(N) "string string"
				}
				[2]=>
				array(2)	{
					["payment_list::date"]=>
					string(N) "string string"
					["payment_list::price"]=>
					string(N) "string string"
				}

			}
		}
	:
	:

I don't check with heavy database, but the overhead of these program will be 
small thing. Anyway if you use these methods, you don't worry about trailing [0].

_______________________________________________________________
Masayuki Nii/Masayuki Nii <msyk at msyk.net> <msyk at mac.com>:iChat Ready
Web Site <http://msyk.net> / INTER-Mediator [for Web App] http://msyk.net/im
OME [Email] http://mac-ome.jp / Tutoring Sevice http://msyk.net/tutoring.html



More information about the FX.php_List mailing list