コード例 #1
0
ファイル: import.php プロジェクト: alex63530/thelia
use Thelia\Model\ProductAssociatedContent;
if (php_sapi_name() != 'cli') {
    throw new \Exception('this script can only be launched with cli sapi');
}
require __DIR__ . '/../core/bootstrap.php';
$thelia = new Thelia\Core\Thelia("dev", true);
$thelia->boot();
$faker = Faker\Factory::create();
// Intialize URL management
$url = new Thelia\Tools\URL();
$con = \Propel\Runtime\Propel::getConnection(Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
    $stmt = $con->prepare("SET foreign_key_checks = 0");
    $stmt->execute();
    clearTables($con);
    $stmt = $con->prepare("SET foreign_key_checks = 1");
    $stmt->execute();
    $material = createMaterials($con);
    $color = createColors($con);
    $brands = createBrands($faker, $con);
    $folders = createFolders($faker, $con);
    $contents = createContents($faker, $folders, $con);
    $categories = createCategories($faker, $con);
    echo "creating templates\n";
    $template = new \Thelia\Model\Template();
    $template->setLocale('fr_FR')->setName('template de démo')->setLocale('en_US')->setName('demo template')->save($con);
    $at = new Thelia\Model\AttributeTemplate();
    $at->setTemplate($template)->setAttribute($color)->save($con);
    $ft = new Thelia\Model\FeatureTemplate();
    $ft->setTemplate($template)->setFeature($material)->save($con);
コード例 #2
0
ファイル: import.php プロジェクト: ncowan15/FoodApp3
            $day = $data[4];
            $mealTime = $data[5];
            createMealPlanComponent($mealPlanId, $foodId, $quantity, $mealTimeDescription, $day, $mealTime);
            ++$lines;
        }
        echo $lines . " meal plan components added\n";
        fclose($handle);
    }
}
/*
	Main Execution
*/
try {
    echo "Food App 3.0 Import Data Script\n";
    echo "-------------------------------\n";
    clearTables();
    createDefaultUser();
    loadNutritionTargets();
    loadFoods();
    loadFoodComponents();
    loadRecipeSteps();
    loadReviews();
    loadAlternates();
    loadMealPlans();
    loadMealPlanComponents();
    echo "Successful completion\n";
} catch (Exception $e) {
    echo "Exception: " . $e->getMessage();
    // Note #1: a file handle may be open at this point - but PHP will close it
    // Note #2: would use a finally clause to close file handles, but it is not supported
    // in PHP 5.4