rahulmes
Posts: 4
|
| Posted: 02/11/2011, 4:53 AM |
|
I am a newcomer to PHP and CCS. Let us say I have a form with multiple rows, which represent multiple records to be inserted into a database. These rows are generated through an editable grid, with auto new row functionality (as in a CodeCharge demo). All rows are submitted at the same time to the server with the Submit button. However, before inserting each record into the database, I need to generate an ID for each row being submitted. How can I do this?
Any help would be greatly appreciated on this. Thanks.
|
 |
 |
datadoit
|
| Posted: 02/11/2011, 5:15 AM |
|
Clarify whether or not you're aware of the database field's Auto
Increment feature before we proceed.
|
|
|
 |
rahulmes
Posts: 4
|
| Posted: 02/11/2011, 4:54 PM |
|
Thanks for the reply.
Yes. I am aware of the auto increment feature. But, the IDs to be generated are based on the user who has logged in.
If say user A has logged in, the ID should be A(xx), if user B has logged in the ID should be B(yy). xx has to be set for each row after querying the database and set as Max(UserID for A)+1. Similarly, yy has to be set for each row after querying the database and set as Max(UserID for B)+1.
Therefore, it is also important that I have to set the ID before inserting the row and then insert it into the database before generating the ID for the next row, since the ID for the next row is based on the ID for the previous row. So, auto increment may not work for me.
Hope this clarifies my query.
|
 |
 |
iii_carlos
Posts: 1
|
| Posted: 03/10/2011, 11:42 PM |
|
Quote rahulmes:
Thanks for the reply.
Yes. I am aware of the auto increment feature. But, the IDs to be generated are based on the user who has logged in.
If say user A has logged in, the ID should be A(xx), if user B has logged in the ID should be B(yy). xx has to be set for each row after querying the database and set as Max(UserID for A)+1. Similarly, yy has to be set for each row after querying the database and set as Max(UserID for B)+1.
Therefore, it is also important that I have to set the ID before inserting the row and then insert it into the database before generating the ID for the next row, since the ID for the next row is based on the ID for the previous row. So, auto increment may not work for me.
Hope this clarifies my query.
I am a newbie too,
In my case, everytime I add, edit, delete a record I need to create a rowversionID which is stored in another table and this rowversionID must be save in those related table.
I have almost achieve this using a stored procedure.
My only problem now is how to set and retrieve the OUT parameters from CodeCharge. I'm using WAMP
|
 |
 |
jjrjr2
Posts: 131
|
| Posted: 03/12/2011, 1:12 PM |
|
Do this in AfterExecuteInsert event for adding records
or in
AfterExecuteUpdate for updating records
Another place might be in the On Validate action
Have a hidden control attached to your table with this ID field
In the On Validate populate that hidden field with your calculated value for this special ID
I have done that sort of stuff with both methods
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
Real Web Development At: http://RealWebDevelopment.us |
 |
 |
|