[FX.php List] FX slowness on FMS13
Nick
whatdoyouwant at gmail.com
Thu Apr 30 14:04:27 MDT 2015
This section takes a long time:
$request = new FX($ServerIP, $Port,$dataSourceType );
$request->SetDBData($fmdb,$Layout,'1');
$request->SetDBUserPass($fmAccount, $fmPass);
You can trim some of the class initialization time off of it by using clone
here, and putting the "new FX" part above the while loops so it only runs
once,
For example, inside the while/if loop, do:
$request_new = clone($request);
$request_new->AddDBParam( 'FieldName', trim($LineData );
$result = $request_new->FMNew();
It still won't help with the actual network requests, but the cpu time will
be less.
On Tue, Apr 14, 2015 at 1:59 PM, csinfo <csinfo at criticalsolution.com> wrote:
> I have a PHP/FX solution that will read a text file line by line and
> write it to FileMaker.
> The PHP script is run from a windows client command line in this format:
> php myuploadscript.php “thefile.txt”
> Using FX as the “engine”.
> This has been working nicely until we upgraded to FMS13, it still works
> but very slow. The IT dept has done extensive testing and tracing and says
> it is the FX library where the slowness occurs. I know my code may not be
> using FX correctly so I have 2 questions:
>
> 1. Is someone willing to look at the part of the script that does the
> writing to see if there is a better way (below)
> 2. Could a subset of fx.php be written so the overhead in FX is
> minimized? (So only functions needed are included)
>
> Any other ideas?
> Thanks in advance, John F
>
> This is the main guts of my PHP script:
>
> <?php
> // command line usage: php mof.php "sampleMOF.txt"
>
> require_once ('FX/FX.php’);
>
> //this data is usually in a server.php include file
> $Port='80’;
> $fmAccount='xmluser';
> $fmPass='xmlpass';
> $dataSourceType = 'FMPro12';
> $fmdb=‘MyDatabase.fmp12';
> $ServerIP='10.77.87.13'; //customer fm13 server
>
> ini_set("auto_detect_line_endings", true);
>
> $Mypath ='c:/common/gcad/MOF/';
> $Layout=‘MyLayout';
>
> //get filename from command line param
> $n=1;
> while ($n <= 2):
> {
> eval('$d'. $n .' = $argv[$n];');
> }
> $n++;
> endwhile;
>
> $MyInputFile = $d1;
>
> //open the file and read/write line by line
> echo "MOF:writing ".$MyInputFile." to FM\n";
>
> $handle = @fopen($Mypath.$MyInputFile, "r");
> if ($handle) {
>
> while (($LineData = fgets($handle,1000)) !== false)
> {
>
> //actually write the line fo FM
> if (strlen($LineData) > 1)
> {
> $linecount=$linecount+1;
> $request = new FX($ServerIP, $Port,$dataSourceType );
> $request->SetDBData($fmdb,$Layout,'1');
> $request->SetDBUserPass($fmAccount, $fmPass);
> $request->AddDBParam( ‘FieldName', trim($LineData );
> $result = $request->FMNew();
>
> }
> //echo $LineData."\n";
> }
>
> if (!feof($handle)){
> echo "Error: unexpected fgets() fail\n";
> }
> fclose($handle);
> }
>
> echo $linecount . " lines written to FM\n";
> ?>
>
>
>
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20150430/b7a4f844/attachment.html
More information about the FX.php_List
mailing list