示例#1
0
#!/usr/bin/env php
<?php 
/**
 * Script for creating and loading database
 * Execute "php load.oracle.php --help" for help
 */
require_once realpath(dirname(__FILE__) . '/lib/Cli.php');
$cli = new Cli(array('fromVerison|f-s' => "Specify from which version it have to update", 'toVersion|t-s' => "Specify to which version it have to update"));
echo "Starting UPDATE application script...\n";
/**
 * @var MongoCollection
 */
$db = $cli->getResource('mongo');
$baseDir = rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'updates';
if (!file_exists($baseDir)) {
    echo "Update directory does not exist.\n";
    exit(0);
}
$dir = dir($baseDir);
$currentVersionFile = $baseDir . DIRECTORY_SEPARATOR . 'current';
// this block executes the actual statements that were loaded from
// the schema file.
try {
    // let the user know whats going on (we are actually creating a
    // database here)
    if ('testing' != APPLICATION_ENV) {
        echo 'Writing Database for environment <' . APPLICATION_ENV . '> in (control-c to cancel): ' . PHP_EOL;
        for ($x = 3; $x > 0; $x--) {
            echo $x . "\r";
            sleep(1);
        }
 * Script for creating and loading database
 * Execute "php load.oracle.php --help" for help
 */
// Initialize the application path and autoloading
require_once 'lib/Cli.php';
$cli = new Cli(array('drop|d' => 'Drop database and data', 'file|f=s' => 'Load file'), false);
try {
    /**
     * @var MongoCollection
     */
    if ($cli->getOption('e') === null) {
        throw new Exception('Need environment param');
    }
    global $db;
    global $drop;
    $db = $cli->getResource('mongo');
    $cli->getResource('cachemanager');
    // let the user know whats going on (we are actually creating a
    // database here)
    if ('testing' != APPLICATION_ENV) {
        echo 'Writing Database for environment <' . APPLICATION_ENV . '> in (control-c to cancel): ' . PHP_EOL;
        for ($x = 3; $x > 0; $x--) {
            echo $x . "\r";
            sleep(1);
        }
    }
    $env = $cli->getOption('e');
    $yamlFile = $cli->getOption('f');
    if (!$yamlFile) {
        $yamlFile = APPLICATION_PATH . '/..' . '/data/default/db/data.mongodb.' . $env . '.yml';
    }