Unknown98 Posted January 27, 2011 Share Posted January 27, 2011 Is is possible, to have a field "copy" data from another field in the same table? Say, I have "user_name" and "username" fields. If data is inserted into "user_name", can I set "username" to automatically copy the data from the "user_name" field? It would have the same effect as inserting data into both fields, but with only having to insert data into one of them. Quote Link to comment https://forums.phpfreaks.com/topic/225808-is-it-possible/ Share on other sites More sharing options...
mikosiko Posted January 27, 2011 Share Posted January 27, 2011 possible?... sure it is.... but correct... sure is not. any reason why you want to do that? Quote Link to comment https://forums.phpfreaks.com/topic/225808-is-it-possible/#findComment-1165793 Share on other sites More sharing options...
Unknown98 Posted January 27, 2011 Author Share Posted January 27, 2011 Because I am working with a content management system -- PHP Fusion -- and for some reason I can't add my custom field to the default SQL insert query when somebody registers. Apparently the field has to start with user_, and I didn't do that a year ago when I set up the database. When someone registers, they can choose their city via a drop-down box. For some reason, the way the CMS is built, I can't add their city to the database unless the DB field starts with user_. It would be a LOT of work to weed through all the pages and lines of code and change everywhere where it calls for the city, from just '$data['city']' to $data['user_city']. Thus why I was wondering if I could create a new field, user_city, and insert their city into that when they register. Then, have the "city" field copy the user_city info, so I wouldn't have to look through thousands of lines of code and change a ton of variables. If you know another way of doing this that's better, I'm all ears I know it's not correct or proper, but at the time I wasn't aware the field had to start with the user_ prefix. Quote Link to comment https://forums.phpfreaks.com/topic/225808-is-it-possible/#findComment-1165819 Share on other sites More sharing options...
mikosiko Posted January 27, 2011 Share Posted January 27, 2011 maybe I'm going to ask the obvious but.... - did you ask about your problem in the PHP-Fusion Forum? - did you read the PHP-Fusion Manual starting in pages 40 and up? prefix seems to be optional or anything. replace across multiples files should no be a problem (almost a piece of cake if well controlled) using a good editor... and if everything fail.... then.... TRIGGER http://dev.mysql.com/doc/refman/5.0/en/triggers.html Quote Link to comment https://forums.phpfreaks.com/topic/225808-is-it-possible/#findComment-1165831 Share on other sites More sharing options...
Unknown98 Posted January 28, 2011 Author Share Posted January 28, 2011 Yes I did. They wern't quite sure, but came to the conclusion that the database field had to start with the prefix user_. I will figure something out I guess Quote Link to comment https://forums.phpfreaks.com/topic/225808-is-it-possible/#findComment-1166330 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.