Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8061 > unrolled thread

Reset Auto Increment to lower value

Started bymakamo66@gmail.com
First post2013-01-10 09:55 -0800
Last post2013-01-11 11:38 -0800
Articles 10 — 5 participants

Back to article view | Back to comp.lang.php


Contents

  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

#8061 — Reset Auto Increment to lower value

Frommakamo66@gmail.com
Date2013-01-10 09:55 -0800
SubjectReset Auto Increment to lower value
Message-ID<97b43e2f-5732-421d-9c6b-19463c9e930e@googlegroups.com>
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. 

[toc] | [next] | [standalone]


#8063

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2013-01-10 20:17 +0000
Message-ID<kcn7le$5j4$1@dont-email.me>
In reply to#8061
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

[toc] | [prev] | [next] | [standalone]


#8066

FromCaptain Paralytic <paul_lautman@yahoo.com>
Date2013-01-11 02:05 -0800
Message-ID<05757de0-324f-4df3-af9d-2871a2eeb976@ck1g2000vbb.googlegroups.com>
In reply to#8061
On Jan 10, 5:55 pm, makam...@gmail.com wrote:
> I need to create a tiles table that has a structure like this forhttp://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.

If you are uaing MySQL then this is the default behaviour:
http://stackoverflow.com/questions/3804845/auto-increment-usage-in-composite-key

[toc] | [prev] | [next] | [standalone]


#8067

Frommakamo66@gmail.com
Date2013-01-11 05:55 -0800
Message-ID<b2348e8c-e235-480c-8db9-c097a3cc854f@googlegroups.com>
In reply to#8066
On Friday, January 11, 2013 5:05:54 AM UTC-5, Captain Paralytic wrote:
> On Jan 10, 5:55 pm, makam...@gmail.com wrote:
> 
> > I need to create a tiles table that has a structure like this forhttp://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.
> 
> 
> 
> If you are uaing MySQL then this is the default behaviour:
> 
> http://stackoverflow.com/questions/3804845/auto-increment-usage-in-composite-key

This didn't work
CREATE TABLE `tiles` (  
	`sub_tile` ENUM('1','2','3') NOT NULL,
	`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,  
	`user_id` INT(22)
 )

[toc] | [prev] | [next] | [standalone]


#8068

From"M. Strobel" <sorry_no_mail_here@nowhere.dee>
Date2013-01-11 15:05 +0100
Message-ID<alakhqF5km6U1@mid.uni-berlin.de>
In reply to#8067
Am 11.01.2013 14:55, schrieb makamo66@gmail.com:
> On Friday, January 11, 2013 5:05:54 AM UTC-5, Captain Paralytic wrote:
>> On Jan 10, 5:55 pm, makam...@gmail.com wrote:
>>
>>> I need to create a tiles table that has a structure like this forhttp://www.myownmealplanner.com:
--cut
>>
>>> 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.
>>
>>
>>
>> If you are uaing MySQL then this is the default behaviour:
>>
>> http://stackoverflow.com/questions/3804845/auto-increment-usage-in-composite-key
> 
> This didn't work

what?

> CREATE TABLE `tiles` (  
> 	`sub_tile` ENUM('1','2','3') NOT NULL,
> 	`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,  
> 	`user_id` INT(22)
>  )
> 

[toc] | [prev] | [next] | [standalone]


#8069

FromCaptain Paralytic <paul_lautman@yahoo.com>
Date2013-01-11 08:18 -0800
Message-ID<a53b0a8e-c7f7-4bc8-afeb-974f21b1932e@r14g2000vbe.googlegroups.com>
In reply to#8067
On Jan 11, 1:55 pm, makam...@gmail.com wrote:
> On Friday, January 11, 2013 5:05:54 AM UTC-5, Captain Paralytic wrote:
> > On Jan 10, 5:55 pm, makam...@gmail.com wrote:
>
> > > I need to create a tiles table that has a structure like this forhttp://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.
>
> > If you are uaing MySQL then this is the default behaviour:
>
> >http://stackoverflow.com/questions/3804845/auto-increment-usage-in-co...
>
> This didn't work
> CREATE TABLE `tiles` (
>         `sub_tile` ENUM('1','2','3') NOT NULL,
>         `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
>         `user_id` INT(22)
>  )

Why would it work, you haven't specified a composite primary key?

[toc] | [prev] | [next] | [standalone]


#8070

FromLuuk <luuk@invalid.lan>
Date2013-01-11 20:07 +0100
Message-ID<ng46s9-tpa.ln1@luuk.invalid.lan>
In reply to#8067
On 11-01-2013 14:55, makamo66@gmail.com wrote:
> According to the manual

which manual?

> I can't restart auto-increment with a lower value than it has already displayed

if it cannot be donne, according to the manual as you state,
than i cannot be done....

> so this needs to be done with php somehow.

eve with php it cannot be done,
if your manual says that it cannot be done...




[toc] | [prev] | [next] | [standalone]


#8071

FromLuuk <luuk@invalid.lan>
Date2013-01-11 20:22 +0100
Message-ID<ic56s9-sua.ln1@luuk.invalid.lan>
In reply to#8061
On 10-01-2013 18:55, makamo66@gmail.com wrote:
> I need to create a tiles table that has a structure like this for http://www.myownmealplanner.com:
>

try fixing this error,
it will give you some knowledge about how to build a php-enabled 
website.........

i got it by visiting:
http://myownmealplanner.com/mealplans/edit/13


Missing Method in MealplansController

Error: The action edit is not defined in controller MealplansController

Error: Create MealplansController::edit() in file: 
app/Controller/MealplansController.php.
  <?php
class MealplansController extends AppController {


	public function edit() {

	}

}

Notice: If you want to customize this error message, create 
app/View/Errors/missing_action.ctp

Stack Trace
  •CORE/Cake/Routing/Dispatcher.php line 186 → 
Controller->invokeAction(CakeRequest)


•CORE/Cake/Routing/Dispatcher.php line 161 → 
Dispatcher->_invoke(MealplansController, CakeRequest, CakeResponse)


•APP/webroot/index.php line 92 → Dispatcher->dispatch(CakeRequest, 
CakeResponse)

[toc] | [prev] | [next] | [standalone]


#8072

Frommakamo66@gmail.com
Date2013-01-11 11:37 -0800
Message-ID<58fc3bac-3759-43ef-9364-0ce3a3fabb12@googlegroups.com>
In reply to#8061
I was asked at another forum why I want a sub_tile_id and this is my explanation. I'd like to know if it is even really necessary after all. 
The jquery at http://myownmealplanner.com/mealplans/add contains the following code (see the view source):

for (var i=1;i<100;i++){
        $( "#draggable" + i ).draggable();
		}
		
Each draggable div uses the primary key of the tiles table to create its own name, for example draggable1, draggable2,..., and on up to draggable100. The tile id (primary key) gives the draggable div its name and I am looping through 100 of these. If I have five users who each have 20 meal tiles then I have already exhausted all of the names available at 100 (5 times 20 being 100). Of course I could just loop over 200 meal tiles instead, keep adding users and keep looping over ever more meal tiles but it seems like a bad idea. Wouldn't the jquery slow down quite a bit if I loop through for example 500 tiles? If instead each user has his own set of meal tiles then I would grab the user id and the sub_tile_id so it would never be more than maybe 10 or 20 to loop through.

[toc] | [prev] | [next] | [standalone]


#8073

Frommakamo66@gmail.com
Date2013-01-11 11:38 -0800
Message-ID<f7d75df0-6283-4620-bfc4-7cf511f7804c@googlegroups.com>
In reply to#8072
Why did you go to an edit page that doesn't exist? I don't think I have a navigation link to it so why did you look for it?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web