Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #8063
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Reset Auto Increment to lower value |
| Date | 2013-01-10 20:17 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <kcn7le$5j4$1@dont-email.me> (permalink) |
| References | <97b43e2f-5732-421d-9c6b-19463c9e930e@googlegroups.com> |
On Thu, 10 Jan 2013 09:55:59 -0800, makamo66 wrote: > I need to create a tiles table that has a structure like this for > http://www.myownmealplanner.com: > > user_id sub_tile_id 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3 etc. > I can't just create new tables for new users because I'm using cakephp > and that would require new models, views, and controllers for every new > table. How do I get the sub_tile_id to auto_increment starting at every > new user id? According to the manual I can't restart auto-increment with > a lower value than it has already displayed so this needs to be done > with php somehow. You could try using SQL something along the lines of: insert into table ( user_id, sub_tile_id ) values ( 'current_user_id', count( select sub_tile_id where user_id = 'current_user_id' ) + 1 ); I *think* something like that should increment sub_tile_id on a per user_id basis, but it's not really a php solution, more of an sql one. -- Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Reset Auto Increment to lower value makamo66@gmail.com - 2013-01-10 09:55 -0800
Re: Reset Auto Increment to lower value Denis McMahon <denismfmcmahon@gmail.com> - 2013-01-10 20:17 +0000
Re: Reset Auto Increment to lower value Captain Paralytic <paul_lautman@yahoo.com> - 2013-01-11 02:05 -0800
Re: Reset Auto Increment to lower value makamo66@gmail.com - 2013-01-11 05:55 -0800
Re: Reset Auto Increment to lower value "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-01-11 15:05 +0100
Re: Reset Auto Increment to lower value Captain Paralytic <paul_lautman@yahoo.com> - 2013-01-11 08:18 -0800
Re: Reset Auto Increment to lower value Luuk <luuk@invalid.lan> - 2013-01-11 20:07 +0100
Re: Reset Auto Increment to lower value Luuk <luuk@invalid.lan> - 2013-01-11 20:22 +0100
Re: Reset Auto Increment to lower value makamo66@gmail.com - 2013-01-11 11:37 -0800
Re: Reset Auto Increment to lower value makamo66@gmail.com - 2013-01-11 11:38 -0800
csiph-web