Beispiel #1
0
$objParameters = new QCliParameterProcessor('growth-group-import', 'ALCF Growth Group Importer Script');
$objParameters->AddDefaultParameter('server', QCliParameterType::String, 'Server/Host of the MySQL Database');
$objParameters->AddDefaultParameter('dbname', QCliParameterType::String, 'Database Name of the MySQL Database');
$objParameters->AddDefaultParameter('username', QCliParameterType::String, 'Username of the MySQL user');
$objParameters->Run();
$objMySqli = new mysqli($objParameters->GetDefaultValue('server'), $objParameters->GetDefaultValue('username'), null, $objParameters->GetDefaultValue('dbname'));
$objMinistry = Ministry::LoadByToken('growth');
if (!$objMinistry) {
    exit('No GG Ministry Found');
}
$objResult = $objMySqli->Query('SELECT * FROM growth_group_structure order by id;');
while ($objRow = $objResult->fetch_array()) {
    $objStructure = new GrowthGroupStructure();
    $objStructure->Name = $objRow['name'];
    $objStructure->Save();
}
$objResult = $objMySqli->Query('SELECT * FROM growth_group_location order by id;');
$objParentGroupArray = array();
while ($objRow = $objResult->fetch_array()) {
    $objGrowthGroupLocation = new GrowthGroupLocation();
    $objGrowthGroupLocation->Location = $objRow['location'];
    $objGrowthGroupLocation->Longitude = $objRow['longitude'];
    $objGrowthGroupLocation->Latitude = $objRow['latitude'];
    $objGrowthGroupLocation->Zoom = $objRow['zoom'];
    $objGrowthGroupLocation->Save();
    $strTokens = explode('(', $objGrowthGroupLocation->Location);
    $objParentGroup = Group::CreateGroupForMinistry($objMinistry, GroupType::GroupCategory, trim($strTokens[0]), 'Growth Groups in ' . $objGrowthGroupLocation->Location);
    $objGroupCategory = new GroupCategory();
    $objGroupCategory->Group = $objParentGroup;
    $objGroupCategory->Save();