17487 Posts in 4473 Topics by 1978 members
|Go to End|
29 May 2008 at 10:47pm
I need to add about 250 new members from an older site to a SS site.
I am not planning to enter them one by one through the CMS GUI.
Do you have a script which would be useful?
I can extract the member records into any format, but I see no "import" functions on the Silverstripe side.
If I end up using some mysql "INSERT INTO ..." scripting, what are the *essentual* fields, I can't find much in the way of documentation of this part of the app. ... soz I don't break the database for the front-end.
1 June 2008 at 1:16pm
Hmm there might be a CSV importer someones used to do this. I would just do it via mysql - look at the member table and just fill those in. For the critical fields open PHPMyAdmin on the member table and view the structure for what you need to pass through, whats optional and what has defaults.
1 June 2008 at 4:39pm
Do you have them in CSV format?
2 June 2008 at 4:01pm
Yeah, I have control of the database they are coming from, so I can create them in any format (from csv to sql )
I was more concerned about the sensitivity of Silverstripe & what field *needed* to have stuff in them.
(... again, where's the documentation!)
To quote an respected engineer I worked with: "Without documentation, there is no design."
13 July 2008 at 5:19pm Last edited: 13 July 2008 5:23pm
... after a long pause ....
I have constructed an sql script which is valid when I import via phpmyadmin,
but the inserted members do not appear in the security group "members" (created earlier) when viewed via the CMS.
(even after .../db/build)
So ... are there some *necessary* fields, or have I got something wrong in the sql
How are they associated with the security groups?
INSERT INTO `Member` (`ClassName`,`FirstName`,`Surname`,`Email`,`Password`,`Occupation`,`Country`) VALUES
('Member','Alan ','Todd ','Alan Todd','NULL',' Magnate','NZ'),
('Member','Bob ','Robb ','Bob Robb','NULL',' Associate Member','NZ');
13 July 2008 at 5:47pm
So there's an *index* file (`Group_Members`) which associates the member to the group, thus requiring another sql script.
So if the two new members are given index 15 & 16, and the target group is index "5" in the `Group` table, then:
INSERT INTO `Group_Members` (`ID` ,`GroupID` ,`MemberID`)VALUES
(NULL , '5', '15'),
(NULL , '5', '16');
It then means somehow capturing the autoincrement values assigned to the new members from the first sql insert.
14 July 2008 at 3:53pm
One option for determining the IDs is to set the member IDs yourself. As long as you don't choose an ID which is already taken, there's no reason why you can't bypass the auto incrementor.
INSERT INTO Member (ID, Email) VALUES (10, 'firstname.lastname@example.org')
INSERT INTO Group_Member (MemberID, GroupID) VALUES (10, 5)
4 October 2008 at 5:21am
I was trying to extend the CMS to add a field to bulk add users, but my time is better spent elsewhere, so I'm doing this directly through MySQL. Once I have added the users (and all the fields I added were Email, Surname, FirstName, Password - these are the steps I take to update the database. In the code below the number 5 represents regular users:
-- update groups to include all members, all these users will
-- get set as User Group 5
INSERT INTO Group_Members (MemberID,GroupID)
FROM Member where ID not in (
Select distinct MemberID from Group_Members
-- group maintenance
-- remove leftover group member items
DELETE FROM Group_Members WHERE MemberID NOT IN (
Select ID from Member
-- here's how i updated the created field, and forced the
-- password to be in plaintext
UPDATE Member set Created=Now()
WHERE ISNULL(Created) ;
|Go to Top|