Migrating from one Name Style to another?

13 years 2 months ago #152411 by creativedynamo
Migrating from one Name Style to another? was created by creativedynamo
Hi!

I've upgraded to cb1.3.1 to stay current (though my question shouldn't be affected by the 1.2 -> 1.3.1 migration from what I can see) and I've run all the Tools successfully after the upgrade.

Originally, I set up my Name Style (General tab of the CB configuration) to be a Single Name Field, but now due to another component I depend upon, I need to change the Name Style to "First and Last Name Field". Making the change and saving it is easy enough, but now I'll need to go in and split that single name field into a firstname and lastname and inject that data into the appropriate place in the db.

After looking around, I see _comprofiler has the field names (firstname/middlename/lastname), but all values are NULL so it looks like I wouldn't want to inject the data here as it appears to be pulling it from elsewhere. _users has the data I need to work with, but it only has the single-named field "Name" so it's not apparent that I should attempt to add two new fields in there "firstname"/"lastname" and populate those fields with the broken down contents of "name".

Which route should I go to convert from the single name to the first/last name on my Joomla(1.5.8) site? What tables/field should I be looking to create/populate/update?

Thanks!

-creativedynamo

What table/field should I be looking at?

Please Log in to join the conversation.

13 years 2 months ago #152595 by creativedynamo
Replied by creativedynamo on topic [solved] Re: Migrating from one Name Style...
After doing some digging around, I managed to cobble together a MySQL statement which isn't perfect, but does a good enough job for me.

Firstly, looks like I was wanting to take the NAME field from the "jos_users" table and dump it into the FIRSTNAME and LASTNAME fields for "jos_comprofiler".

Here's the MySQL Query that did the trick for me:
update `jos_comprofiler`,`jos_users` SET firstname = substr(`jos_users`.`name`,1,instr(`jos_users`.`name`,' ')-1), lastname = substr(`jos_users`.`name`,instr(`jos_users`.`name`,' ')+1) where `jos_comprofiler`.`id` = `jos_users`.`id`;

Quirks of this one-line fix:

If the users' names have two fields (e.g. John Doe) everything works as expected.
If the users' names have a single name (e.g. Prince), their one name will show up as their last name and their first name will be blank.
If the users' names have two first names or a middle initial (e.g. Mary Ann or Harry S Truman), everything after their first name is dumped into their last name field.

It may not be good enough for your needs, but seeing as there wasn't anything I could search for on the boards here talking about it, this should at least give you a good starting point if you want to tweak it for your needs.

Caveat: Use at your own risk. It worked for me as I said, and it'll probably work for you, but try testing it out on a blank table first or something. ;)

-creativedynamo
The following user(s) said Thank You: nant

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.185 seconds

Facebook Twitter LinkedIn