You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pdd-order-api/env.php

198 lines
4.9 KiB
PHTML

11 months ago
<?php
if ($_GET['pwd'] !== 'zmkm') {
return ;
}
function checkExtension($module_name) {
if (extension_loaded($module_name)) {
echoMsg("$module_name is exist", 'green');
} else {
echoMsg("$module_name is not exist", 'red');
}
}
function echoMsg($message, $color) {
echo sprintf('<div style="color:%s;">%s</div><br/>', $color, $message);
}
require 'vendor/autoload.php';
// 应用目录
$rootDir = dirname(__FILE__);
$appDir = 'app';
ini_set('default_charset', 'utf-8');
include $rootDir . '/zc-framework/zc.php';
Zc::init($rootDir, $appDir);
$log = Zc::getLog('env');
$mConfig = array (
'error_mode' => 'bool', // bool or exception
'default_group' => 'ay-s1',
'connections' => array (
'ay-s1' => array (
'master' => array (
'db_id' => 'zc.master',
'dbms' => 'mysql',
'hostname' => '123.57.64.23',
'port' => '3306',
'username' => 'honor_test',
'password' => 'hello1234',
'pconnect' => false,
'charset' => 'utf8',
'database' => 'honor_test'
)
),
'ay-db1' => array (
'master' => array (
'db_id' => 'zc.master',
'dbms' => 'mysql',
'hostname' => '10.163.2.82',
'port' => '3306',
'username' => 'apollo3HKa9',
'password' => '2%2eO@L8ad3%',
'pconnect' => false,
'charset' => 'utf8',
'database' => 'honor_apollo'
)
)
)
);
try {
Zc::dump(gethostname());
$mdb = new ZcDb($mConfig);
zc::dump(microtime());
$ret = $mdb->useDbIdOnce('ay-db1')->query('show master status');
Zc::dump($ret);
zc::dump(microtime());
$ret = $mdb->useDbIdOnce('ay-db1')->query('select * from admin limit 1');
Zc::dump($ret);
} catch (Exception $ex) {
Zc::dump($ex);
}
exit;
$config = array (
'error_mode' => 'bool', // bool or exception
'default_group' => 'ay-s1',
'connections' => array (
'ay-s1' => array (
'master' => array (
'db_id' => 'ay-s1.master',
'dbms' => 'mysql',
'hostname' => '10.162.202.248',
'port' => '3306',
'username' => 'jxzndz',
'password' => 'iSw@#22JSfd',
'pconnect' => false,
'charset' => 'utf8',
'database' => 'jmonitor'
)
),
'ay-db1' => array (
'master' => array (
'db_id' => 'ay-db1.master',
'dbms' => 'mysql',
'hostname' => '10.251.201.102',
'port' => '3306',
'username' => 'jxzndz',
'password' => 'iSw@#22JSfd',
'pconnect' => false,
'charset' => 'utf8',
'database' => 'jmonitor'
)
)
)
);
$db = new ZcDb($config);
$tbls = $db->useDbIdOnce('ay-s1')->queryFirstColumn("select table_name from information_schema.tables where table_schema='jmonitor'");
foreach ($tbls as $i => $tbl) {
$mcount = $db->useDbIdOnce('ay-s1')->queryFirstField('select count(*) from %b', $tbl);
$scount = $db->useDbIdOnce('ay-db1')->queryFirstField('select count(*) from %b', $tbl);
$diff = $tbl . ': ' . $mcount . ' -> ' . $scount . ' -> ' . ($mcount - $scount);
$log->info($diff);
echo $diff . '<br/>';
// if ($i == 3) {
// break;
// }
}
exit;
Zc::dump($mdb);
//Zc::dump($ret);
exit;
Zc::dump('Hostname: ' . gethostname());
if (!empty($_GET['ns'])) {
Zc::dump($_SERVER);
}
checkExtension('redis');
checkExtension('ming');
$config = Zc::C();
//********************************* Test DB **********************************
$c = $config[ZcConfigConst::DbConfig]['connections']['zc']['master'];
Zc::G('mysql_connect start');
$link = mysql_connect($c['hostname'], $c['username'], $c['password'], true);
Zc::G('mysql_connect end');
if (!$link) {
echoMsg('mysql_connect mysql_error: ' . mysql_error() . ', mysql_errno: ' . mysql_errno(), 'red');
} else {
echoMsg('mysql_connect success', 'green');
}
Zc::G('mysql_select_db start');
mysql_select_db($c['database'], $link);
Zc::G('mysql_select_db end');
Zc::G('mysql_query start');
$res = mysql_query('select * from vender where vender_id = 116272', $link);
Zc::G('mysql_query end');
if (!$res) {
echoMsg('mysql_query mysql_error: ' . mysql_error() . ', mysql_errno: ' . mysql_errno(), 'red');
} else {
echoMsg('mysql_query success', 'green');
}
mysql_close($link);
//********************************* Test Redis Session **********************************
$redisConfigs = array();
$redisConfigs['masterSessionRedis0'] = $config[ZcConfigConst::Session]['options']['master_servers'][0];
$redisConfigs['slaveSessionRedis0'] = $config[ZcConfigConst::Session]['options']['slave_servers'][0];
$redisConfigs['bizCacheRedis0'] = $config[redis]['bizCache'];
foreach ($redisConfigs as $name => $c) {
Zc::G("$name start");
try {
$redis = new Redis();
$connected = $redis->connect($c['host'], $c['port'], $c['timeout'], NULL, 100);
if (!$connected) {
echoMsg("$name connect fail", 'red');
} else {
echoMsg("$name connect success", 'green');
}
} catch (Exception $ex) {
echoMsg(print_r($ex, true), 'red');
}
Zc::G("$name end");
}
Zc::dump(Zc::G());