本文整理汇总了PHP中Cli::getResource方法的典型用法代码示例。如果您正苦于以下问题:PHP Cli::getResource方法的具体用法?PHP Cli::getResource怎么用?PHP Cli::getResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cli
的用法示例。
在下文中一共展示了Cli::getResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: realpath
#!/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);
}
示例2: Cli
* 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';
}