Re: Newbie question - other way than insert statement?

From: Date: Tue, 20 Nov 2001 22:22:59 +0000
Subject: Re: Newbie question - other way than insert statement?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-14484@lists.php.net to get a copy of this message
No, but SQL is your friend, and is actually easier than messing around with recordsets, once you get the hang of it. The exact form of your INSERT statement will depend a bit on the database are you using, but the following is typical. This is MySQL syntax, I believe PostgresSQL is similar. INSERT INTO tablename ( firstname, lastname, phone_number) VALUES ( '$strFirst', '$strLast', '$strPhoneNo' ) and if you are truly confident and believe your table structure will NEVER change, you could shorten it to INSERT tablename VALUES ( '$strFirst', '$strLast', '$strPhoneNo' ) Sometimes you just UPDATE UPDATE tablename SET firstname = '$strFirst', lastname = '$strLast', phone_number = '$strPhoneNo' WHERE primary_key_field = '$UniqueID' If any rows are returned by a SELECT statement determines whether you use an INSERT or an UPDATE, but then you have to do that to determine whether you .AddNew or .Edit. Hope this helps - Miles Thompson PS Of course _nothing_ beats the ease of use and clarity of FoxPro and its descendants. <g> At 11:00 PM 11/20/2001 +0100, Daniel Schwab wrote:
Hi I came from ASP and I'm sort of a newbie. I'm sure you'll see that after my question :-) I'm looking for a way to insert data in an mysql db but not with an insert into statement. Is there any way i can do some sort of: mydb.myfieldname = $myvalue ?? (same as in asp with recordsets: rs!fieldname = value) any way to do that in a similar manner? thanks for your help daniel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.db (#14484) next »