[FX.php List] Getting "-recid" for 1 record

Gjermund Gusland Thorsen ggt667 at gmail.com
Wed Jul 19 00:50:48 MDT 2006


Way over your head? Please take a look at the following links:

http://www.php.net/list
http://www.php.net/explode
http://www.php.net/key

ggt667

On 7/19/06, AC <ac at pottnerconsulting.ca> wrote:
> In FileMaker I have a table of users and a Login table with only 1
> record in it.  FX writes the user supplied login & password to the
> login tables record, a calc field returns the ID of the matching user
> record (if any).  I'm doing it this way because I couldn't figure out
> how to check for a case sensitive password in the user table and I
> don't want to allow write access to the user table.
> To edit the Login record I needed its recid and I know I'm only
> returned 1 record so I figured there should be a non looping way of
> getting that number.
> Gtt's code did exactly that;
>
> $ResultAll=$Search->FMFindAny();
> list($TheRecID, $TheModID)=explode('.', key($ResultAll['data']));
>
>
> I'm just getting started with PHP & FX.
> Unfortunately the code you wrote is way over my head, hopefully it'll
> make sense one of these days.
>
> Thanks for everyone's help.
>
>
>
> On Jul 18, 2006, at 8:27 PM, DC wrote:
>
> > sorry...
> >
> > i didn't take a really close look at what you had... i think gtt's
> > answer will fix your problem...
> >
> > however, i looked at your original question and it seems that if you
> > get more than one record returned in the found set you may want an
> > array of recids and their modcounts? is that the case?
> >
> > here's how you could do that (I took your challenge that you wanted to
> > avoid repeat loops so this makes use of PHP's array functions
> > instead):
> >
> > <?php
> > // show how to get an assoc array from FX.php data
> > // with rec id as key and mod count as value
> > // dummy data similar to FX.php array
> > $ResultAll['data'] = array('1000.11'=>1,'2000.22'=>2);
> >
> > // get the keys which are the in the format recid.modcount
> > $keys_array = array_keys($ResultAll['data']);
> > // map array to custom function
> > // generate dots for explode
> > $dots_array = array_fill(0,count($keys_array),'.');
> > $modid_recid_array = (
> >                               array_map('explode_to_assoc',
> >                               $dots_array,
> >                               $keys_array)
> >                               );
> > print_r($modid_recid_array);
> >
> > // ---------------------------------------
> > // assumes 2 items separated by $str incoming
> > // returns assoc array with item 1 as key
> > // and item 2 as value
> > function explode_to_assoc ($str, $arr) {
> >       list($i,$j) = explode($str,$arr);
> >       return array($i=>$j);
> > }
> > ?>
> >
> > archived at:
> >
> > http://dbmscan.com/snippets/
> >
> > in the FX helpers section.
> >
> >
> > enjoy!
> > dan
> >
> > On Jul 18, 2006, at 5:13 PM, AC wrote:
> >
> >> This is the command I'm using:
> >> $ResultAll=$Search->FMFindAny();
> >> list($TheRecID, $TheModID)=explode('.', ($ResultAll['data']));
> >> echo('RecID=' . $TheRecID);
> >>
> >> The result I get is;
> >> RecID=Array
> >>
> >>
> >>
> >> On Jul 18, 2006, at 4:05 PM, DC wrote:
> >>
> >>> take out $key
> >>>
> >>> AC had written:
> >>>> This works for me;
> >>>> $ResultAll=$Search->FMFindAny();
> >>>> list($key)=each($ResultAll['data']);
> >>>> $TheRecID=strtok($key, ".");
> >>>> I can't get this to work, did I miss type it or does it require the
> >>>> for each loop?
> >>>> $ResultAll=$Search->FMFindAny();
> >>>> list($TheRecID, $TheModID)=explode('.', $key($ResultAll['data']));
> >>>> On Jul 18, 2006, at 3:09 PM, Gjermund Gusland Thorsen wrote:
> >>>>> This is how I do it
> >>>>> ---
> >>>>> list( $recid, $modid ) = explode( '.', $key( $r['data'] ) );
> >>>>> ---
> >>>>>
> >>>>> ggt667
> >>>>>
> >>>>> On 7/18/06, AC <ac at pottnerconsulting.ca> wrote:
> >>>>>
> >>>>>> > If you just want the key I believe this will work, but I
> >>>>>> haven't tried:
> >>>>>> > list($key) = each($ResultAll['data']);
> >>>>>> > $recid = strtok($key, ".");
> >>>>>>
> >>>>>> Yes it does work, thanks.
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> On Jul 18, 2006, at 1:52 PM, Andrew Denman wrote:
> >>>>>>
> >>>>>> > Don't remember where I found this, but it's useful if you only
> >>>>>> have one
> >>>>>> > record returned. The first line will give you the key and data
> >>>>>> of the
> >>>>>> > first
> >>>>>> > set of data in the $ResultAll['data'] array (and according to
> >>>>>> the php
> >>>>>> > docs,
> >>>>>> > advance the pointer to the next set of data).  Second and third
> >>>>>> lines
> >>>>>> > will
> >>>>>> > break out the recid and modid.
> >>>>>> >
> >>>>>> > list($key, $data) = each($ResultAll['data']);
> >>>>>> > $recid = strtok($key, ".");
> >>>>>> > $modid = strtok(".");
> >>>>>> > $Field_Data = $data['Field_Name'][0];
> >>>>>> >
> >>>>>> > If you just want the key I believe this will work, but I
> >>>>>> haven't tried:
> >>>>>> > list($key) = each($ResultAll['data']);
> >>>>>> > $recid = strtok($key, ".");
> >>>>>> > $modid = strtok(".");
> >>>>>> >
> >>>>>> > Andrew Denman
> >>>>>> >
> >>>>>> > -----Original Message-----
> >>>>>> > From: fx.php_list-bounces at mail.iviking.org
> >>>>>> > [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of AC
> >>>>>> > Sent: Tuesday, July 18, 2006 12:30 PM
> >>>>>> > To: fx.php_list at mail.iviking.org
> >>>>>> > Subject: [FX.php List] Getting "-recid" for 1 record
> >>>>>> >
> >>>>>> > If I know that only 1 record is returned then I can use the
> >>>>>> following
> >>>>>> > to get data from that record;
> >>>>>> >
> >>>>>> > $ResultAll=$Search->FMEdit();
> >>>>>> > $ResultOne=current($ResultAll['data']);
> >>>>>> > echo('ID=' . $ResultOne['ID'][0]);
> >>>>>> >
> >>>>>> >
> >>>>>> >
> >>>>>> > How would I do the same thing to get the "-recid" without doing
> >>>>>> the
> >>>>>> > following loop thing?
> >>>>>> >
> >>>>>> > foreach($ResultAll['data'] as $key=>$ResultOne){
> >>>>>> >     $TheRecIDModNum=explode('.',$key);
> >>>>>> >     $TheRecID=$TheRecIDModNum[0];
> >>>>>> > }
> >>>>>> >
> >>>>>> > _______________________________________________
> >>>>>> > FX.php_List mailing list
> >>>>>> > 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
> >>>>>> > http://www.iviking.org/mailman/listinfo/fx.php_list
> >>>>>> >
> >>>>>> >
> >>>>>>
> >>>>>> _______________________________________________
> >>>>>> FX.php_List mailing list
> >>>>>> 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
> >>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
> >>>>>
> >>>>>
> >>>> _______________________________________________
> >>>> FX.php_List mailing list
> >>>> 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
> >>> http://www.iviking.org/mailman/listinfo/fx.php_list
> >>>
> >>>
> >>
> >> _______________________________________________
> >> FX.php_List mailing list
> >> 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
> > http://www.iviking.org/mailman/listinfo/fx.php_list
> >
> >
>
> _______________________________________________
> 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