Subject Re: creating unique key : usingprimair key and foreign key
From Ken Mayer <dbase@nospam.goldenstag.net>
Date Sat, 6 Feb 2021 11:39:36 -0800
Newsgroups dbase.getting-started

On 2/6/2021 11:30 AM, Ronnie MacGregor wrote:
> In article <hZjyQaL$WHA.1872@ip-AC1E04A7>, dbase@nospam.goldenstag.net
> says...
>
>> I have had to do something along those lines in some of my own code on
>> the web for applications when I needed the primary key right after the
>> record was saved.
>  
> The following should be multiuser and session proof in PHP.
> We don't have the same luxury with dbf AutoInc . . .
>
> <?php
>
> $myConn = new mysqli("localhost", "UserName", "Password");
>
> $query = "INSERT INTO myTable VALUES (
>    'Text',
>    'MoreText',
>    'Something',
>    'Something Else'
>    )";
>
> $myConn->query($query);
>
> $NewRecordID = $myConn->insert_id;
>
> ?>

I tried playing with some of the suggestions for this kind of thing, but
I gave up. I just chose to do a search. It works in the tables I've used
it for, but I know what's supposed to be unique and what's not, too. :)

(I never got around to dealing with object-oriented PHP, I've been fine
with the non-object version, so the -> syntax isn't in my code.)

Ken


--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm