php - How can this be done using an InnoDB table type? -


i have following code uses myisam table type because of see comment in create code. how can done using innodb.

actually, new article id generated based on user, , starts 1 each user. however, cannot done if table type changed. how can achieved when using innodb?

create table `articles` (     `artcid` int(10) not null auto_increment,     `artcuserid` int(10) not null default '0',     `artctitle` varchar(50) not null default 'no title defined',     `arcttime` timestamp not null default current_timestamp,     primary key (`artcuserid`, `artcid`)// see part here , see image below. ) collate='utf8_general_ci' engine=myisam; 

screencapture

you can work trigger posted in other thread or manually.

pseudocode:

start transaction; -- needs in transaction ... select @lastid := max(iditem) item idarticulo = ?; insert item (idarticulo, iditem, texto) values (?, @lastid+1, ?); ... commit;  handle first-time situation: max(iditem) --> ifnull(max(iditem), 1) 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -