RE: [PHP-WIN] SQL SELECT while INSERTING
| From: | Asendorf, John | Date: | Fri, 08 Dec 2000 13:10:05 +0000 |
| Subject: | RE: [PHP-WIN] SQL SELECT while INSERTING | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-4378@lists.php.net to get a copy of this message | ||
I don't think it will be too much of a problem, it's not an extremely active
database and I'm going to run the select directly after the insert so
hopefully I won't have too much of a problem.
If it was a more active database I would worry about it, but I'm not going
to at this point.
---------------------
John Asendorf - jasendorf@lcounty.com
Web Applications Developer
http://www.lcounty.com - NEW FEATURES ADDED DAILY!
Licking County, Ohio, USA
740-349-3631
Vah! Denuone Latine loquebar? Me ineptum. Interdum modo elabitur.
> -----Original Message-----
> From: MokLC [mailto:moklc@dreamvale.com]
> Sent: Thursday, December 07, 2000 9:25 PM
> To: Php-Windows (E-mail)
> Subject: Re: [PHP-WIN] SQL SELECT while INSERTING
>
>
> What happens when another record has been added after the
> insert, and before
> the select max??
>
>
> Mok Lai Chuan
> e-Consultant
> Dreamvale.com Pte Ltd
> 111 North Bridge Road
> #21-01
> Singapore 179098
> Tel : (65)584 2576
> Fax : (65) 234 2248
>
> ----- Original Message -----
> From: "Asendorf, John" <JAsendorf@lcounty.com>
> To: "Michael Rudel" <Michael.Rudel@in-gmbh.de>; "Php-Windows
> (E-mail)"
> <php-windows@lists.php.net>
> Sent: Thursday, December 07, 2000 9:57 PM
> Subject: RE: [PHP-WIN] SQL SELECT while INSERTING
>
>
> > That's what I'm looking for SELECT MAX, that should do it! Thanks
> everyone!
> >
> > ---------------------
> > John Asendorf - jasendorf@lcounty.com
> > Web Applications Developer
> > http://www.lcounty.com - NEW FEATURES ADDED DAILY!
> > Licking County, Ohio, USA
> > 740-349-3631
> >
> > Vah! Denuone Latine loquebar? Me ineptum. Interdum modo elabitur.
> >
> >
> >
> >
> >
> > > -----Original Message-----
> > > From: Michael Rudel [mailto:Michael.Rudel@in-gmbh.de]
> > > Sent: Thursday, December 07, 2000 3:42 AM
> > > To: 'Asendorf, John'; Php-Windows (E-mail)
> > > Subject: AW: [PHP-WIN] SQL SELECT while INSERTING
> > >
> > >
> > > Hey John,
> > >
> > > here's my code, it works well:
> > >
> > > function insert( $str_sql, $file = "", $line = "" )
> > > {
> > > $this->db_exec( $str_sql, $file, $line );
> > >
> > > // $this->free_result();
> > >
> > > // Tabellenname aus dem INSERT-Statement extrahieren
> > > $table = strstr( $str_sql, "INTO" );
> > > $table = substr( $table, 5 );
> > > $table = substr( $table, 0, strpos( $table, " " ) );
> > >
> > > // Dummy-Select, da beim INSERT keine Spaltennamen
> > > zurückgegeben
> > > werden
> > > $str_sql = "SELECT * FROM ".$table;
> > > $this->db_exec( $str_sql, $file, $line );
> > >
> > > // Feldnamen der ersten Spalte ermitteln
> > > $field_name = odbc_field_name( $this->sql_result, 1 );
> > >
> > > // $this->free_result();
> > >
> > > // SELECTiert den Auto-Inkrement-Wertes der
> INSERT-Operation
> > > $str_sql = "SELECT MAX(".$field_name.") FROM ".$table;
> > > $this->db_exec( $str_sql, $file, $line );
> > >
> > > // Holt den Auto-Inkrement-Wert
> > > $auto_inc = odbc_result( $this->sql_result, 1 );
> > >
> > > // Gibt den Auto-Inkrement-Wert an die aufrufende
> > > Funktion zurück
> > > return ( $auto_inc );
> > > }
> > >
> > > Sorry, it uses my class, but I think you get the Hack while
> > > reading, isn't
> > > it ??
> > >
> > > My own ODBC-Class is attached, so you can experiment if
> you like. It
> > > contains
> > > automatic Error-Handling as well.
> > >
> > > If you have Questions about it, ask ... you've got my @ddy
> > > now. Or perhaps I
> > > could send you a few examples.
> > >
> > > Good Luck and have Fun with it =8)
> > >
> > > Greetinx,
> > > Mike
> > > (Germany)
> > >
> > > P.E.: You could join me to your consortium >8)=)
> > >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Asendorf, John [mailto:JAsendorf@lcounty.com]
> > > Gesendet: Mittwoch, 6. Dezember 2000 20:42
> > > An: Php-Windows (E-mail)
> > > Betreff: [PHP-WIN] SQL SELECT while INSERTING
> > >
> > >
> > > Hello all,
> > >
> > > Have a quick question. Can I select an auto-incrementing key
> > > at the same
> > > time I am 'inserting into' a new record...
> > >
> > > using Access ODBC
> > >
> > > like this
> > >
> > > $sql = "INSERT INTO blocked (page,name,email,attempt) VALUES
> > > ('$page','$name','$email','$attempt')
> > >
> > > AND GET THE KEY FROM THIS ENTRY HERE
> > >
> > > ;";
> > >
> > > Thanks all,
> > >
> > > John
> > >
> > > ---------------------
> > > John Asendorf - jasendorf@lcounty.com
> > > Web Applications Developer
> > > http://www.lcounty.com - NEW FEATURES ADDED DAILY!
> > > Licking County, Ohio, USA
> > > 740-349-3631
> > >
> > > Vah! Denuone Latine loquebar? Me ineptum. Interdum modo elabitur.
> > >
> > >
> > >
> > >
> > >
> > > --
> > > PHP Windows Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> > > For additional commands, e-mail: php-windows-help@lists.php.net
> > > To contact the list administrators, e-mail:
> > > php-list-admin@lists.php.net
> > >
> > >
> > >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-windows-help@lists.php.net
> > To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
> >
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> For additional commands, e-mail: php-windows-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>