Re: How make auto_increment field visisble but read only

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: How make auto_increment field visisble but read only
Groups: php.general 
Request: Send a blank email to php-general+get-357@lists.php.net to get a copy of this message
If you add a new row to your table, just fill all the fields except the ID. The ID will be set automatically. If you do a simple "SELECT * FROM tbl_xyz", you can read whatever you want. The ID will not change. If you do an update, say: "UPDATE tbl_xyz SET a=.... WHERE ID=xxx;". So, the ID won't be touched and changed. You must not submit a query in which you SET the ID to a new value. That makes no sense. If you delete a row, you say "DELETE FROM tbl_xyz WHERE ID=xxx;". That's all. So if you don't touch the ID explicitly, which I wouldn't recommend at all BTW, everything will work as you like. Where else should the changes of the table come from than from an UPDATE statement that YOU programmed!? HTH Steff >Hello tricky world, > >Probably a trivial problem, too bad its not yet for me: > >I have an mysql auto-increment, not_null, primary key named ID. How can I display it and prevent >any changes? > >Thanks everybody again. > >Helmut > >

« previous php.general (#357) next »