I had a need to import user data into Joomla with the Community Builder RC1 component installed. After a bit of discovery I found a method.
First, I had to export my users from a proprietory Access database to something I could import using phpMyAdmin. I ultimately found that MySQL seems to like tab delimited files better, since phpMyAdmin likes to have a character set surrounding each cell for import purposes, and Excel doesn't export csv that way (at least not to my knowledge).
Before any of these changes were attempted, I exported the tables marked for updating. Backups are good juju....
Once that was done, I had to form the data to prepare for import. The first table I imported was jos_users. I used a nice php script found somewhere on the net.
Replace $TABLENAME, $FILENAME, $DATABASENAME, $PASSWORD, $USERNAME, and $HOSTNAME with appropriate values.
# first get a mysql connection
$dbh=mysql_connect ("$HOSTNAME", "$USERNAME", "$PASSWORD") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("$DATABASENAME");
$fcontents = file ('./$FILENAME');
# expects the csv file to be in the same dir as this script
for($i=0; $i
$arr = explode("\t", $line);
#if your data is comma separated
# instead of tab separated,
# change the '\t' above to ','
$sql = "insert into $TABLENAME values ('".
implode("','", $arr) ."')";
mysql_query($sql);
echo $sql ."\n";
if(mysql_error()) {
echo mysql_error() ."\n";
}
}
?>
Use the UPDATE command to convert passwords to MD5 in a SQL query like this:
UPDATE `jos_users` SET `password`=md5(`tmp_pass`)
That would set the password field in jos_users to an md5 hashed value found in a temporary column called tmp_pass. You could then delete the unused column.
I then found that there is yet another couple of tables to update called jos_comprofiler, jos_core_acl_aro, and jos_core_acl_groups_aro_map. Do the updates to these tables in this order, since it's easy to spot the patterns in data, so you can modify your original Excel data to fit.
Fun!
Just where I place my rants and raves...
Saturday, July 15, 2006
Importing User Data Into Joomla
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2008
(15)
-
►
April
(10)
- Symantec Endpoint Protection...again
- 2.5 Days to uninstall Symantec Endpoint Protection...
- SmugMug was my choice
- Symantec Endpoint Protection...blech
- Leveraging Microsoft Indexing Service in the Enter...
- Word and VBA Forms
- Misys Tiger Financial Analysis Report Parsing usin...
- Misys PM Refund List Parser
- PLC Data Collection
- Homegrown Remote Assistance
-
►
April
(10)
About Me
- John Croson
- I'm a middle-aged geek, father of two wonderful children, and husband to a saintly wife. I love motorcycles, especially old cafe racers, like the 50's to 70's era racers. Mike "The Bike" Halewood is my hero. I love my job as an IT Manager at IHBSOnline.com. It allows me to use my skills as a technologist. If it weren't for my past retail experience, I'd just be a introverted geek, instead of an outgoing, fun, geeky guy.
0 comments:
Post a Comment