6 Replies Latest reply on Oct 11, 2013 9:20 AM by pethar

    php - newFindCriterion with quotes

    pethar

      Hi

       

      In a normal FileMaker Pro find question you can quote the whole text in a field or just a part of the search text to limit the result to match the exact quoted phrase.

       

      Is it possible to achieve this when searching the FM-database through the php-module?

       

      Have tried to add quoted find criterions with combinations of both single and double quotes with or without escape character. The result are the same, "no records found". The same quoted search phrase works fine when searching the same database with FileMaker client, and all other find commands (without quotes) works find thorough php.

       

      We are currently using FileMaker Pro Server 11.

       

       

      Peter

        • 1. Re: php - newFindCriterion with quotes
          Mike Duncan

          Like this...

           

          $find->addFindCriterion('Your_Field', '"' . $search_value . '"');

           

          or for exact match of a word or phrase...

           

          $find->addFindCriterion('Your_Field', '=="' . $search_value . '"');

           

          Basically the API hands off the values in filemaker to perform the find, so you can cat wildcard characters into your values.

          • 2. Re: php - newFindCriterion with quotes
            pethar

            Yes thats the expected result…

             

            This is the result produced when running the find command from php

             

            $find->addFindCriterion('Your_Field',  $search_value );

            where $search_value =

             

            10-010                    -> matches: 10-010, 10-0101, 010-01011

            =10-010                    -> matches: 10-010, 10-010 anything, but not 10-0101

             

            ==10-010                    -> no records found

            "10-010"                    -> no records found

             

             

            The server is running FileMaker Pro server 11 on OS X 10.7.

             

            It would be much appreciated if someone could verify if  the error is produced from OS X 10.7 (running on MacPro where 10.7 is max), or if it's fixed with FileMaker Pro server 12 (still running on 10.7)?

            • 3. Re: php - newFindCriterion with quotes
              LyndsayHowarth

              Are the fields defined as text fields?

               

              I wonder if you need to excape the minus... maybe it is trying to do maths.

               

               

              10-010                    -> matches: 10-010, 10-0101, 010-01011   ## This is a begins-with or contains and should find 10-0102

              =10-010                    -> matches: 10-010, 10-010 anything, but not 10-0101  ## by anything do you mean it will find 10-0102  ?

               

              ==10-010                    -> no records found  ## exact match  so should find 10-010 and nothing else

              "10-010"                    -> no records found     ## literal match  so should find 10-010 and nothing else

               

              interesting... do you want to post an export from that field so I can experiment. (If I do it with data I enter I might miss something.)

               

              - Lyndsay

              • 4. Re: php - newFindCriterion with quotes
                databuzz

                Hi Peter,

                 

                You can search via the PHP API using quote marks and achieve the same result as you can using the FileMaker Pro client - however you need to make sure your PHP installation isn't altering the input values that contain the quote marks (you can see this for yourself if you add some debugging code to the results page to show the raw HTTP REQUEST values. e.g. by adding this to the bottom of the page:

                 

                <p>

                    <pre><?php print_r($_REQUEST); ?></pre>

                </p>

                 

                 

                I've encountered an issue with some servers where the magic_quotes_gpc setting in the php.ini file is turned ON - this will prevent your "exact match" searches from working as expected. I would first check to see if the magic_quotes_gpc setting in the php.ini file is ON - if so set it to OFF and try again (restart Apache in between).

                 

                Otherwise examine what the actual REQUEST values are and that might give you a clue as to why they're not working, e.g. quote marks getting escaped etc.

                 

                HTH,

                Andrew

                • 5. Re: php - newFindCriterion with quotes
                  pethar

                  They are text fields.

                   

                  Everything works when the same database files are upgraded to FileMaker Pro 12 Server, running on Mac OS X 10.8.5.

                  I guess the problem are related to OS X 10.7 or the combination 10.7 and FM Pro server 11.

                  • 6. Re: php - newFindCriterion with quotes
                    pethar

                    magic_quotes_gpc, _runtime and _sybase are all Off in FileMaker Pro server php.ini.

                     

                    Also verified with

                    <?php

                    phpinfo()

                    ?>

                     

                    The result are the same when the find command are hard coded in the php-file.

                     

                    The problem is gone when running the same php-files and FM Pro database files on FM Pro Server 12 and OS X 10.8.

                     

                    I guess the problem are OS X 10.7 (which are the limit on the current webserver harware), or the combination 10.7 and FM Pro Server 11.