Updating record in Database
I have this form on my site where a user can enter many strings and save it to their account. But I'm not sure how to go about it.
Instead of cre开发者_如何学运维ating a whole new user, with new values, I'd just like to update a single entry in the database.
For example if a user wanted to add another email address to their account, how would I sort of create an array, and add that to their existing space in the database?
Thank you
You could store the field as XML (SQL Server works well with it) if you want something more structured than a simple list. This breaks normalization rules, of course, and complicates your application slightly (having to parse that field when you fetch rows, and having to build it when updating rows), but that's a choice you have to make for yourself.
are you looking for Update query in SQL
UPDATE [Cube].[dbo].[IdentityCheck]
SET [Name] = <Name, text,>
WHERE <Search Conditions,,>
INSERT PersonValues (PersonID, ValueTypeID, Value)
SELECT 234, 118, 'email2@example.com'
-- for person 234, insert value type 118 (email address) with said email address
For more information on this type of storage see EAV database.
i had a project similar to that and stored the input in a CSV format.
"email@example.com","email2@example.com"
then you can use this function to convert the CSV string to an array for manipulation in php
精彩评论