
epicrecipe
Members-
Posts
35 -
Joined
-
Last visited
About epicrecipe
- Birthday 02/14/1972
epicrecipe's Achievements
-
How to Find Unique / Distinct Values in an Array?
epicrecipe replied to epicrecipe's topic in Other Internet Technologies
I figured it out. I'll continue my people/fruit example: <? $Search = new FX($serverIP,$webCompanionPort); $Search->SetDBData('FMPFile.fp7','LayoutName'); $Search->SetDBPassword($webPW,$webUN); $Search->AddDBParam('Fruit',' * '); $SearchResult=$Search->FMFind(); $FoundCount = $SearchResult['foundCount']; ?> This would return my mythical record set. larry, banana johnny, apple sally, banana bobby, pear billy, mango I studied the result of print_r($SearchResult); to learn how FX.php delivers XML produced by FileMaker. From there, I used a loop to build a new array. The new array is built on a single 'column' from the $SearchResult array. <? foreach($SearchResult['data'] as $SearchKey=>$SearchRecord) { $FruitArray[] = $SearchRecord['Fruit'][0]; } ?> Now I can pimp out my new array as needed... $FruitArray; would result: Array ( [0] => banana [1] => apple [2] => banana [3] => pear [4] => mango ) $FruitUnique = array_unique($FruitArray); would result: Array ( [0] => banana [1] => apple [2] => pear [3] => mango ) $ValuesPerFruit = array_count_values($FruitArray); would result: Array ( [banana] => 2 [apple] => 1 [pear] => 1 [mango] => 1 ) $FruitCount = count($FruitUnique); would result: 4 etc... HTH, Shannon -=-=- -
How to Find Unique / Distinct Values in an Array?
epicrecipe replied to epicrecipe's topic in Other Internet Technologies
Thanks Andy. That is probably the final step in the process. I first need to figure out how to get all the values of a column of multiple records into a single array. I've found basic examples all over the net, but haven't figured out how to do it with an array returned via FX.php. I think my answer is somewhere in the realm of Associative arrays. (?) Any other ideas? I'll post my solution if I can figure it out. Shannon -=-=- -
I use FX.php, FM7, FMS7A, PHP 5.1.2 running on IIS. How can I use PHP to extract a found count for unique values from single column? Here is a mythical record set. larry, banana johnny, apple sally, banana bobby, pear billy, mango I'd like to find the number of unique fruits (4). One option is to order the record set and then run looping logic to disregard duplicates. This seems inefficient. How might I accomplish this using FX.php? Any ideas on using arrays / associative arrays? Thank you, Shannon
-
How can FX.php query multiple related tables?
epicrecipe replied to epicrecipe's topic in Other Internet Technologies
Okay gang, I fixed this. Rereading my OP, my description is a bit confusing. Let's see if I can befuddle you further. Here's the dealio on querying related tables on a single page: 1) In FileMaker, I have Table A and Table B. In order to allow a many-to-many relationship, I have a third table, Table AB. 2) I am searching LayoutTableA. 3) My code above is fine (although TableB should be TableAB). What does not work: In FileMaker, I added a related field to LayoutTableA: Table AB::Field9. In FX.php, I used the above code to query that field and I got strange errors that led me to upgrade PHP, test for nulls and a couple other goose chases. What does work: In FileMaker, I added a related field to LayoutTableA via a portal Table AB::Field9. In FX.php, I used my code to query that field and it worked perfectly. Hope this helps someone... Shannon -=-=- -
error code 958 missing parameter from query
epicrecipe replied to wcakey's topic in Other Internet Technologies
The full error description I have for 958 is "No RecID, unknown record to add or edit or delete, attempting to edit an uneditable field" Is it possible the script is attempting to write to a field that rendered uneditable in FileMaker? Something like a serial number or a registration number? Either don't write to that field or allow edits in FM. Or are the bad chars being written to a field that can only accept numbers? You might need to validate the date before it gets inserted, either by javascript or PHP. Hope this helps! Shannon -=-=- -
I am running FM7SA, PHP 5.1.2, Win 2003 and FX.php v4.2 I am using FX.php to search a layout that has fields from multiple related tables. $Search = new FX($serverIP,$webCompanionPort); $Search->SetDBData('FMFile.fp7','LayoutTableA'); $Search->SetDBPassword($webPW,$webUN); $Search->AddDBParam('Field1','$post-value1'); $Search->AddDBParam('Field2',$post-value2); $Search->AddDBParam('TableB::Field9',$post-value3); $SearchResult=$Search->FMFind(); $FoundCount = $SearchResult['foundCount']; foreach($SearchResult['data'] as $SearchKey=>$SearchRecord) { ... } When it Works I can perform the query directly in the FM layout just fine. It only pukes via PHP. If I delete the related field from the layout and remove $Search->AddDBParam('TableB::Field9',$post-value3); they query executes just fine (of course, I'm only searching one table). I am able to query multiple tables just fine in instances where the related field is not null. In addition, this query DOES work if the result finds values in the related field. It breaks if the related field is left empty (i.e. if all fields are left empty and the user just clicks "Find", a common scenario) When it Doesn't Work However, if the result has any null values in the related field, I get fatal PHP errors: "Fatal error: Cannot use object of type FX_Error as array" for any line that returns the $SearchResult. (In PHP 4.3.9, the error was "Cannot use a scalar value as an array" on the foreach statement) This one really has me stumped. I suspect PHP cannot properly build the result array because nulls are present. Your Thoughts? Do you have any ideas how I might trap for nulls, but still display results? I'd like the logic to be in PHP, but at this point, I'll consider modifying the FM database or layouts. Or is there a better way to query multiple tables with FX.php? Thank you very much in advance!!! Shannon -=-=-
-
$op-neq problem- multi predicate search.
epicrecipe replied to Kranky's topic in Other Internet Technologies
Garry - yes, the SecondField ('status') has many values. Here is my data set: (32 total records) FirstField: 27 empty, 5 not empty SecondField: 4 'Closed', 28 something other than closed. I'm sorry I wasn't clear. In FileMaker, this gives me the desired result: Request 1: set FirstField = '*' Request 2: set SecondField = 'closed' and check the omit box Result: Success: 3 records where FirstField is not empty and SecondField is not 'closed'. In FX.php, I get the same desired result with: $query -> AddDBParam('FirstField',' * '); $query -> AddDBParam('SecondField','Closed','neq'); $query -> AddDBParam('-lop','or'); $queryResult = $query -> FMFind(); Result: Success: 3 records where FirstField is not empty and SecondField is not closed. I believe this is the answer for the OP, Kranky. Now, I originally tried Andy's suggestion: $query -> AddDBParam('FirstField',' * '); $query -> AddDBParam('SecondField','Closed','neq'); $queryResult = $query -> FMFind(); Result: No Joy: 30 records: 25 records where FirstField is empty and SecondField is not closed AND 3 records where FirstField is not empty and SecondField is not closed AND 2 records where FirstField is empty and SecondField is closed (The only two records NOT found were FirstField is not empty and SecondField is Closed) I get the same result in FileMaker when I perform a find on a single request: Request 1: set FirstField = '*' Request 1: set SecondField = 'closed' Request 1: check the omit box Therefore, setting the "-lop" to "or" allowed me to have multiple find requests where one had the omit box checked. Clear as mud? I DO appreciate your feedback Shannon -
$op-neq problem- multi predicate search.
epicrecipe replied to Kranky's topic in Other Internet Technologies
I am wanting to find records where: FirstField = Not empty AND SecondField = Not 'Closed' I'm looking for a result very similar to the OP. In FileMaker, we'd perform a find using two requests: 1) First Field = "*" and 2) SecondField = "Closed" with the Omit box checked. This code provides the result I needed: <?php include_once('FX/FX.php'); include_once('FX/server_data.php'); $query = new FX ($serverIP, $webCompanionPort); $query -> SetDBData($webDB,$layout); $query -> SetDBPassword($webPW,$webUN); $query -> AddDBParam('FirstField',' * '); // Note the spaces in ' * ' $query -> AddDBParam('SecondField','Closed','neq'); $query -> AddDBParam('-lop','or'); $queryResult = $query -> FMFind(); ?> Now on to my next problem - using FX.php to query multiple values of the same field like FileMaker allows multiple requests in find mode. Thank you and hope this helps, Shannon -
$op-neq problem- multi predicate search.
epicrecipe replied to Kranky's topic in Other Internet Technologies
Can anyone help with this? I am also trying to figure out how to accomplish a multiple request FM7/FMS7A find via FX.php without nesting loops. Thanks! -
How to find using Omit in FX.php
epicrecipe replied to epicrecipe's topic in Other Internet Technologies
Okay, I found an answer that works for me... I replaced $Instance->AddDBParam('FieldName',"FieldValue",$op="eq"); with $Instance->AddDBParam('FieldName',"FieldValue",$op="neq"); The 8 Hours book incorrectly shows the code to be $Instance->AddDBParam('FieldName',"FieldValue",$-op="eq"); and it didn't offer other operators. I found a list of operators in the FX.php source code (FX>FX.php) with $op="bw" being the default (begins with) case 'eq': $currentSearch .= $name . " = '" . $value . "'"; break; case 'neq': $currentSearch .= $name . " != '" . $value . "'"; break; case 'cn': $currentSearch .= $name . " LIKE '%" . $value . "%'"; break; case 'bw': $currentSearch .= $name . " LIKE '" . $value . "%'"; break; case 'ew': $currentSearch .= $name . " LIKE '%" . $value . "'"; break; case 'gt': $currentSearch .= $name . " > '" . $value . "'"; break; case 'gte': $currentSearch .= $name . " >= '" . $value . "'"; break; case 'lt': $currentSearch .= $name . " < '" . $value . "'"; break; case 'lte': $currentSearch .= $name . " <= '" . $value . "'"; break; Hope this helps... Shannon -=-=- -
Hello, I'd like to find a set of records using omit. I can't find an answer in my copy of FX.php in 8 Hours or in the forum. I know how to search a field by a value, how do I find omitted records with that value? Is there a published list of operators used by FX.php? Here's my code: $Instance = new FX($serverIP,$webCompanionPort); $Instance->SetDBData('Database.fp7','Layout'); $Instance->SetDBPassword('user','pass'); $Instance->AddDBParam('FieldName',"FieldValue",$op="eq"); $Instance Result=$Instance->FMFind(); Thanks! Shannon -=-=-
-
display info related to foundCount with FX.php
epicrecipe replied to LML's topic in Other Internet Technologies
kfutter's code is nice and clean and helped me. Thanks for posting! Shannon -=-=- -
Configuring FM7 Advanced for PHP
epicrecipe replied to jbruno's topic in Other Internet Technologies
The FX.php in 8 Hours book covers FMS7A install and config on IIS. The writing in my version has poor editing, but I was able to figure it out. I understand there is a new version, maybe FMWebSchool will offer an upgrade price for it I had all kinds of weird errors with PHP 5.0.0. I rolled back to v4.3.9 and everything worked well. In FM, try adding user "fmsadmin" with full access in File->Define->Accounts & Priviledges under the Accounts tab. FMS7A will use this account to access the FP7 file. Close the file in FM7 when opening it in FMS7A. Again in FM, try adding user "fmxml" with full access in File->Define->Accounts & Priviledges under the Extended Priveleges tab. Make sure XML Publishing is on in the FMS Web Console at http://ipaddress/fmi/config. Try restarting FileMaker and IIS services. You may also need to restart the console and/or the web server. Try connecting via IWP. Turn it on in FM7 and the FMS Web Console. This will tell you if FMS7A is properly connecting to the FP7 file. Try starting with a basic FindAll() FX.php action to test connectivity to a file. Hope this helps. Shannon -=-=- -
Garry meant you can only have one action for each FX instance. If I understand what you're doing, you should be able to have a single FX instance on each page: - page1.php - <form method="post" action="page2.php"> <input type="text" name="FirstName" /> <input type="text" name="LastName" /> <input type="submit" value="Continue to Page 2" /> </form> - page2.php - <?php // Field Vars from page1.php. (stripslashes helps clean data) @$FirstName = stripslashes($_POST['FirstName']); @$LastName = stripslashes($_POST['LastName']); // Create new FX Instance $Add = new FX($serverIP,$webCompanionPort); $Add->setDBData('database.fp7','layout'); // Add the record. $Add->AddDBParam('FirstName',$FirstName); $Add->AddDBParam('LastName',$LastName); $AddResult=$Add->FMNew(); // After all your error traps, you have a successful addition. Grab the recid. foreach($AddResult['data'] as $AddKey=>$AddRecord) // Get FileMaker Record ID $FMRecordID = explode('.',$AddKey); $recid = $FMRecordID[0]; ?> <form method="post" action="page3.php"> <input type="hidden" name="recid" value="<?=$recid?>" /> <input type="text" name="HomePhone" /> <input type="text" name="WorkPhone" /> <input type="submit" value="Continue to Page 3" /> </form> - page3.php - <?php // Field Vars from page2.php. @$recid = $_POST['recid']; @$HomePhone = $_POST['HomePhone']; @$WorkPhone = $_POST['WorkPhone']; // Create new FX Instance $Edit = new FX($serverIP,$webCompanionPort); $Edit->setDBData('database.fp7','layout'); // Edit Parameters. $Edit->AddDBParam('-recid',$recid); $Edit->AddDBParam('HomePhone',$HomePhone); $Edit->AddDBParam('WorkPhone',$WorkPhone); $EditResult=$Edit->FMEdit(); ?> If you want another action for FMFind(), just open another FX Instance and set your find parameters. If you want to keep adding to the same record, keep passing the recid via hidden fields and editing the record. You can also put all this logic in a single PHP page. Just change the form tags to <form method="post" action="script.php?mode=page2">. Then use if statements to check for $mode: <? if (isset($_GET['mode'])) { $mode = $_GET['mode']; } else { $mode = ""; } ?> and deliver content accordingly. Hope this helps! Shannon -=-=-
-
How do I keep adding information into same record?
epicrecipe replied to PHP2005's topic in Other Internet Technologies
I agree, use POST to pass values through each page. <form name="formname" method="post" action="nextpage.php"> If you need to track data across multiple pages for a single record, simply grab the recid early, you can then pass it through each page in a hidden field: <input type="hidden" name="recid" value="<?=$recid?>" />. Another track: create a PHP session variable to store the recid on the server. Then grab it as needed. A client-side cookie may work too (probably not here though). Learn more about PHP sessions, security concerns, etc. at http://www.php.net Hope this helps. Shannon -=-=-