FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Reset Auto Increment to lower value
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Reset Auto Increment to lower value [message #180129 is a reply to message #180127] Thu, 10 January 2013 20:17 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
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(at)gmail(dot)com
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: php unit testing - how to find the right person
Next Topic: Anyone have experience with any php debuggers?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 00:42:14 GMT 2024

Total time taken to generate the page: 0.06896 seconds