[FX.php List] Search Results To Text File

Malcolm Fitzgerald malcolm at notyourhomework.net
Mon Jul 13 13:46:00 MDT 2015


Hi Patricia,

Are you absolutely sure that every field MUST have double quotes around it?

The whole point of CSV is to pass it onto another app. Is the app that 
you are passing the data to rejecting the file?

Malcolm



On 14/07/2015 6:44 am, VanBuskirk, Patricia wrote:
>
> Hi guys, I think I’m really close.  I’m getting it to create the file, 
> but I am struggling with the format. Each field needs to have double 
> quotes around it, as in the following example:
>
> "FSU01","RN260715","Facilities Department - MENDENHALL BUILDING A 
> (MMA) - 969 LEARNING 
> WAY","RN","OTC","OTC","1","OPEN","","5/19/2015","5/19/2016"
>
> "FSU01","RN260815","Procurement Services & Help Desk - UNIVERSITY 
> CENTER - BLDG. A (UCA) - 282 CHAMPIONS 
> WAY","RN","OTC","OTC","1","OPEN","","5/20/2015","5/20/2016"
>
> "FSU01","TSR0299915","Medicine College of Dean's Office - COM 
> -THRASHER BLDG. 1115 W CALL 
> ST","TSR","OTC","OTC","2","OPEN","","5/20/2015","5/20/2016"
>
> Here’s how it’s coming out now.  It is putting a little square when 
> the carriage return should be, and the fields are not being surrounded 
> by quotation marks.  I tried using the $delimiter and $enclosure 
> parameters, but they put random quotation marks in (maybe just around 
> text fields?).  I can get it to echo to the page properly, by using  … 
> ‘”’.$field1.’”,”’.field2 … etc.
>
> Here’s my code:
>
> <?php
>
> define('DEBUG', TRUE);
>
> require_once('FX.php');
>
> require_once('server_data.php');
>
> require_once('FMErrors.php');
>
> $search=new FX(FM_IP, FM_PORT, FM_VERSION);
>
> $search->SetDBData('WorkOrders_TST.fp7','SeeALL');
>
> $search->SetDBUserPass(FM_USERNAME, FM_PASSWORD);
>
> $search->AddDBParam('Status_CD', 'OPEN');
>
> $search->AddDBParam('ExportTimestamp', null);
>
> $search->AddDBParam('REQ_Start_Dt', ' * ');
>
> $search->AddDBParam('REQ_End_Dt', ' * ');
>
> $search->AddDBParam('Descr254', ' * ');
>
> $searchResult = $search->DoFXAction('perform_find');
>
> $fp = fopen("C:\\Temp\\NewOMNI.txt", "w");
>
> echo "<br>Found Records: ".count($searchResult)."<br>";
>
> foreach ($searchResult as $record) {
>
> $linearray=array($record['Business_Unit'],$record['WO_ID'],$record['Descr254'],$record['WO_Type'],$record['Shop_ID']);
>
>     fputcsv ( $fp , $linearray, $delimiter = ',', $enclosure = '"' 
> )."\l" ;
>
> }
>
> fclose($fp);
>
> echo("<br>Error Code: {$search->lastErrorCode}<br>");
>
> echo("FileMaker Error Message: 
> {$errorsList[$search->lastErrorCode]}<br><br>");
>
> echo "Error: ".$searchResult['errorCode'];
>
> ?>
>
> I have been messing with this darn thing for several days now, so any 
> tips or direction given will be greatly appreciated!
>
> Trish
>
> *From:*fx.php_list-bounces at mail.iviking.org 
> <mailto:fx.php_list-bounces at mail.iviking.org> 
> [mailto:fx.php_list-bounces at mail.iviking.org] *On Behalf Of *Steve Winter
> *Sent:* Thursday, July 9, 2015 4:01 PM
> *To:* FX.php Discussion List
> *Subject:* Re: [FX.php List] Search Results To Text File
>
> Hi Patricia
>
> So - if you’re already using FX, then it should be pretty simple. In 
> pseudo code
>
>  1. create a brand new layout and place the fields you need to export,
>     in the order you need to export them on that layout from top to
>     bottom (this may sounds mad, but what it will mean is that when
>     the FX array of records comes back the fields will be in the right
>     order)
>  2. do a find for the records which need to be exported
>  3. use http://php.net/manual/en/function.fopen.php to create a file
>     resource
>  4. feed the file resource and the FX array of returned records into
>     http://php.net/manual/en/function.fputcsv.php which Joel suggested
>  5. close the file using http://php.net/manual/en/function.fclose.php
>
> HTH
>
> Steve
>
>     Hi Steve (and Joel),
>
>     We are currently using FMS 11Adv, but have plans to upgrade to 14
>     as soon as budget is approved (as fast a herd of turtles around here).
>
>     That robot has been in use using a script running plug-in for
>     years, importing orders from the web, then creating a csv of
>     certain info for our PeopleSoft folks to import into their
>     inventory system (which is why ODBC is not an option).  They have
>     very specific formatting that they must have or their import will
>     fail.
>
>     Anywho.... I have replaced the import portion of it through FX,
>     but haven’t yet figured out how to do the export part.
>
>     Thanks again for your responses!
>
>     Trish
>
>
>     -----Original Message-----
>     From: fx.php_list-bounces at mail.iviking.org
>     <mailto:fx.php_list-bounces at mail.iviking.org>
>     [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Steve
>     Winter
>     Sent: Thursday, July 9, 2015 3:36 PM
>     To: FX.php Discussion List
>     Subject: Re: [FX.php List] Search Results To Text File
>
>     Hi Patricia
>
>     There are many different ways to solve this problem ;-)
>
>     Which version of FM server are you using…? it’s certainly possible
>     with both 13 and 14 to export records to csv with a server-side
>     script, so this is going to be the simplest way to go about it.
>
>     Otherwise either FX or the PHP API could also be used with a
>     scheduled task.
>
>     Cheers
>     Steve
>
>
>         Hi Group!
>
>         Is there a way, using fx.php to create a csv text file of
>         search results on the FM or web publishing server?
>
>         Example of how we need the results,
>
>         "FSU01","TSR0002216","Information Technology Services (ITS) -
>         ","TSR","OTC","OTC","2","OPEN","","07/06/2015","07/06/2016"
>         "FSU01","TSR0002316","Arts & Sciences College of -
>         ","TSR","OTC","OTC","2","OPEN","","07/08/2015","07/08/2016"
>         "FSU01","TSR0002916","Information Technology Services (ITS) -
>         ","TSR","OTC","OTC","2","OPEN","","07/09/2015","07/09/2016"
>         "FSU01","TSR0003016","Alumni Association -
>         ","TSR","OTC","OTC","2","OPEN","","07/09/2015","07/09/2016"
>
>         We presently have a "script robot" set up that exports a file
>         every 1/2 hour within a FM client.  We are trying to get rid
>         of that FM installation and automate it through php.  I was
>         actually trying to run a FM script through FM Server, but it
>         seems export is not a permitted script step for server script
>         scheduling.
>
>         Any assistance would be greatly appreciated!
>
>         Trish
>         _______________________________________________
>         FX.php_List mailing list
>         FX.php_List at mail.iviking.org <mailto:FX.php_List at mail.iviking.org>
>         http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
>     Steve Winter
>     +44 777 852 4776
>     steve at bluecrocodile.co.nz <mailto:steve at bluecrocodile.co.nz>
>
>
>
>
>     _______________________________________________
>     FX.php_List mailing list
>     FX.php_List at mail.iviking.org <mailto:FX.php_List at mail.iviking.org>
>     http://www.iviking.org/mailman/listinfo/fx.php_list
>     _______________________________________________
>     FX.php_List mailing list
>     FX.php_List at mail.iviking.org <mailto:FX.php_List at mail.iviking.org>
>     http://www.iviking.org/mailman/listinfo/fx.php_list
>
> Steve Winter
>
> +44 777 852 4776
>
> steve at bluecrocodile.co.nz <mailto:steve at bluecrocodile.co.nz>
>
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

-------------- next part --------------
Skipped content of type multipart/related


More information about the FX.php_List mailing list