I have a table with invoices. Each invoice belongs to a user.
So the table table has id
, user_id
columns.
I want a third column, for example invoice_id that is autoincrement based on the user.
So for example user 1 will have invoices with id 1,2,3,4,5,6,7,8...
And user 2 will also have invoices with id 1,2,3,4,5,6,7,8...
I know I can make a function that checks the last value for a specific user and assign the next but is there no other "easier" more proper way to do this with cakephp
or mysql
?