[FX.php List] Connecting PHP Web Pages with ODBC

Glyn Devine glyn.devine at quickseries.com
Thu Apr 25 13:08:09 MDT 2013


This is more of a PHP question than an FX question but I'll try.

First of all, you installed the FM ODBC driver and set up a DSN right?
(System level DSN if you want it to be accessible to all users on the
machine, User level DSN if you want it accessible only when logged into your
account) 

Once you've done that, running queries is easy. Let's say you've got a table
called Products and you want to print a listing of the field ProductCode
it'd go something like this:

$connect = odbc_connect("Your DSN Name", "filemaker user", "filemaker
password"); //Establish a connection

$query = "SELECT ProductCode FROM Products"; // Your query

$result = odbc_exec($connect, $query); // Execute query

//Loop through results
while(odbc_fetch_row($result)){
  $productcode = odbc_result($result, 1);
  print("$productcode\n");
}

Odbc_close($connect);

Also, regarding FX's speed... In all my experiments, I have never gotten
acceptable speed out of it when writing. I've done all the 'best practice'
stuff, made special layouts, severed relationships, removed calculations,
everything. My FMS is running on a 2.8ghz Xeon Quad Core with 16GB of RAM
and it still took 3-7 seconds to create each record no matter what I tried.
Mine is just one story, Dale has obviously had a different experience, but
that was mine. Never could figure out how to speed it up...



On 13-04-25 2:14 PM, "dealTek" <dealtek at gmail.com> wrote:

> 
> On Apr 25, 2013, at 9:55 AM, John Funk <csinfo at criticalsolution.com> wrote:
> 
>> When creating records  with Fx you have to be sure and use an optimized
>> layout created just for that purpose. Do not use fields that you do not need.
>> With FX all information is inserted/extracted using the Fmresult xml file and
>> that file is created by what fields are on the layout you are using in the
>> query.
>> I have created millions of records with a layout that has 3 of 34 fields and
>> it was very fast. Another hint is to not have related or portals on the
>> layout, if you need to create records in a related field of to a layout for
>> that table using a key. The PHP code seems clunky but I found it to be fast.
>> I also have seen ODBC queries  take a long time especially when modifying a
>> found set. 
>> 
>> The best thing about FX is NO DRIVERS are required so it is more flexible and
>> you can actually use PHP command lines in DOS or MacOS bash commands.
>> John
>> 
>> From: Glyn Devine <glyn.devine at quickseries.com>
>> Reply-To: "FX.php Discussion List" <fx.php_list at mail.iviking.org>
>> Date: Thursday, April 25, 2013 11:28 AM
>> To: "FX.php Discussion List" <fx.php_list at mail.iviking.org>
>> Subject: Re: [FX.php List] Connecting PHP Web Pages with ODBC
>> 
>> ODBC will definitely be faster than FX. FX is dead slow when writing records.
>> You are generally talking multiple seconds per record created.
>> 
>> To use ODBC to write to filemaker in PHP, you will need to install the
>> FileMaker ODBC driver on the same machine PHP is running on. The driver that
>> comes with FileMaker 11 will work fine. I do not recommend the
>> FileMaker-created ODBC drivers from FileMaker discs prior to version 11 ­
>> these also have some pretty terrible speed problems.
>> 
>> Good luck! 
> 
> 
> Hi John Glyn & Dale,
> 
> Thanks for all the helpful tips.
> 
> The thing I am still in the dark about is how to write the php to access the
> filemaker database with ODBC?
> 
> So, as a test I have succesfully created an odbc connection to a (localhost)
> filemaker database (I also will use fmserver soon).
> 
> Now I would like to know a way - using PHP to setup a connection to the
> filemaker database and perform queries from a local webpage.
> 
> Here's some connection info...
> 
> ip = xxx.xxx.xxx.??? - any special port
> USER DSN = test1
> database = MyDB
> 
> I just don't know how to write the ODBC connection code in PHP?
> 
> Any ideas?
> 
> 
> 
> --
> Thanks,
> Dave - DealTek
> dealtek at gmail.com
> [db-3]
> 
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list




More information about the FX.php_List mailing list