* Add chdir and fix run and expect funtion.
This commit is contained in:
+58
-6
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* 本文件创建一个 app 示例,并且通过执行 $app->loadCommon() 方法创建名为 tester 的commonModel对象。
|
||||
* 本文件创建一个 app 实例,并且通过执行 $app->loadCommon() 方法创建名为 tester 的commonModel对象。
|
||||
* This file build a app instance and provide a instance of commonModel named as tester by $app->loadCommon().
|
||||
*
|
||||
* All request of entries should be routed by this router.
|
||||
@@ -13,13 +13,65 @@
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
/* Set the error reporting. */
|
||||
error_reporting(0);
|
||||
error_reporting(E_ALL & E_STRICT);
|
||||
|
||||
$frameworkRoot = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR;
|
||||
|
||||
/* Load the framework. */
|
||||
include '../framework/router.class.php';
|
||||
include '../framework/control.class.php';
|
||||
include '../framework/model.class.php';
|
||||
include '../framework/helper.class.php';
|
||||
include $frameworkRoot . 'router.class.php';
|
||||
include $frameworkRoot . 'control.class.php';
|
||||
include $frameworkRoot . 'model.class.php';
|
||||
include $frameworkRoot . 'helper.class.php';
|
||||
|
||||
$app = router::createApp('pms', dirname(dirname(__FILE__)), 'router');
|
||||
$tester = $app->loadCommon();
|
||||
|
||||
$config->zendataRoot = dirname(__FILE__) . DS . 'zendata';
|
||||
$config->zdPath = "/usr/local/zd/zd";
|
||||
|
||||
function run($result)
|
||||
{
|
||||
global $_result;
|
||||
$_result = $result;
|
||||
return true;
|
||||
}
|
||||
|
||||
function expect($key, $delimiter = ',')
|
||||
{
|
||||
global $_result;
|
||||
echo ">> ";
|
||||
$result = "";
|
||||
|
||||
if(!is_array($_result) and !is_object($_result))
|
||||
{
|
||||
$result = (string) $_result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$keyList = explode(',', $key);
|
||||
$dimension = 1;
|
||||
foreach($_result as $value)
|
||||
{
|
||||
if(is_array($value) or is_object($value)) $dimension = 2;
|
||||
}
|
||||
|
||||
if($dimension == 1) $_result = array($_result);
|
||||
foreach($_result as $object)
|
||||
{
|
||||
foreach($keyList as $key) $result .= zget($object, $key, '') . $delimiter;
|
||||
}
|
||||
$result = trim($result, $delimiter);
|
||||
}
|
||||
echo $result . "\n";
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
function zdImport($table, $yaml, $count = 10)
|
||||
{
|
||||
chdir(dirname(__FILE__));
|
||||
global $app, $config;
|
||||
$dns = "mysql://{$config->db->user}:{$config->db->password}@{$config->db->host}:{$config->db->port}/{$config->db->name}#utf8";
|
||||
$table = trim($table, '`');
|
||||
$commad = "$config->zdPath -c $yaml -t $table -T -dns $dns --clear -n $count";
|
||||
system($commad);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user