Is it worth trying to establish a Persistent FTP Connection?
Hi All,
So before I decided to have our company purchase SmartPill -- indeed, I think it was well before SmartPill existed [FM6ish] -- I had FileMaker compose a whole series of "SnapShot" html reports and then I used this, that or the other plugin to write the html with a starting "PHP Island" security check to a bunch of naming convention Include files. Then the PHP site, based on the Users logon $_SESSION variables the Include path was generated (as per those same naming conventions) and the proper report file was included.
Has been working great for years.
Now, notwithstanding that I can do so much more now with SmartPill -- IIABDFI (if it ain't broke don't fix it) -- I am not going change any of the code (right away), but I do want to DUMP the tired old Plugin(s) for using SmartPill with the PHPx FTP functions.
I have gotten those functions working.
YaY!
As explained in FunctionMaker, FTP_ConnectionSettings() does not actually connect, but loads all the settings into those "Super Globals" from SmartPill that are then used subsequently by the other PHPx FTP functions.
So my question is to ask whether it is worth it to try to make the FTP connection Persistent while I write a thousand or so files every overnight, or whether I can just say, "let it be, computers can handle the load."
I was thinking perhaps that I break up the
FTP_PutFileFromText ( text ; remoteFilePath {; overwrite } )
into three scripts:
FTP_Connect ()
FTP_PutFileFromText_SingleOfLoop ( text ; remoteFilePath {; overwrite } )
FTP_DisConnect()
(and of course, call connect before the loop begins, call SingleOfLoop for each loop iteration and then after exiting the loop call disconnect. Somehow invoking until disconnect the "keepMemory" attribute of the function: PHP_Execute( phpCode {; keepMemory {; timeoutSeconds }} )
So I have two questions:
1. Is it worth it?
2. Am I on the right track for how to rewrite the PHPx functions?
Thanks in advance for any help -- and of course, if the answer to #2 is "No!" then feel free to show me the right track.
Thanks,
Brad
What about Persistent Database Connection?
Hi Again,
Thanks for the great answer.
Apologies for not responding, but no response just meant I was "off to the races" with the answer you provided.
I am posting this question since in one sense it is the same question, but in another sense it is in an entirely different realm.
I have gotten so comfortable with SmartPill that when an external datasource can be reached via SmartPill (other than FileMaker itself... yet), I find it quicker, easier, and more portable to do any SQL that needs to be done via SmartPill *rather* than establishing an External Datasouce (either ODBC Script Commands or ESS) which then depend on precise parallel of the ODBC Drivers from client to client... and then new clients...
So, I am reworking a "Mission Critical Key Data Distribution" routine with SmartPill.
I have to set Last, First, Effective Date, Expiration Date (and so on) from the "GOLD" FileMaker source to a MySQL WebPortal User table, an Oracle User table and an Oracle Provider table.
This is important just for the sake of best, clean and consistent data, and is Mission Critical from the point of view that when a Student is Expelled by the Registrar in FileMaker it needs to prevent that Student from logging onto the WebPortal and the Oracle application.
I would like to have the Outer-Loop just loop through the Found Set and the Inner-Loop be a "Do-It-All" script for the current Person, that way I can do different refreshes for dfferent found sets, probably with 'Batch Instantiation' logic to establish the proper found set. Also, if there is an error, the ones that are done are DONE and the ones that aren't done are UNDONE. If I were to flip inner and outer loops then any error would mean that every person is at some differing stage of UNDONE.
With that scenario, I need three Connections instantiated within SmartPill for each of the three SQL statements to Execute: UPSERT, UPDATE, UPDATE.
In *this* scenario, is it indicated to try to maintain three PHP Connections as Persistent Connections?
... and I guess I should have started with, Is it even Possible?
Thanks again for your original answer, and thanks in advance to anyone that may be able to answer this new case.
Thanks,
Brad
What about Persistent Database Connection?
Hello Brad,
Hmmm, haven't tried this so I can't say but I certainly think it's worth a try. With that said, another approach would be to gather up all the data you need first and then do all your SQL work in a singe PHP call. This would probably allow you to do your SQL work in a transactions as well which may be beneficial.
I've taken this approach with a timesheet transfer between a FileMaker job costing database and a corporate MSSQL database. First, I loop through the records in FileMaker and add to the INSERT statement with each record, and then once my big giant query string is complete, I open a connection and do all the inserts in a single call.
Regards,
Micah
Is it worth trying to establish a Persistent FTP Connection?
Hello Brad,
I'd have to do some testing to really be able to answer the "Is it worth it?" question. Getting things done faster is always preferable, especially if you're uploading hundreds of files. I'm just not sure how "expensive" the connections are.
In regards to your approach, I haven't tried it but that should work. Another thought would be to send a file list to the plug-in and have PHP loop through the list and do the uploading all in a single call. You could also pass in a folder path and have PHP upload all of the files in the folder.
Regards,
Micah