本文整理汇总了PHP中CLISetup::loadDBC方法的典型用法代码示例。如果您正苦于以下问题:PHP CLISetup::loadDBC方法的具体用法?PHP CLISetup::loadDBC怎么用?PHP CLISetup::loadDBC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLISetup
的用法示例。
在下文中一共展示了CLISetup::loadDBC方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
public static function generate($tableName, array $updateIds = [])
{
if (!isset(self::$tables[$tableName])) {
CLISetup::log('SqlGen::generate - invalid table given', CLISetup::LOG_ERROR);
return false;
}
if (!empty(self::$tables[$tableName][0])) {
$tbl = self::$tables[$tableName];
// shorthand
CLISetup::log('SqlGen::generate() - copying ' . $tbl[0] . '.dbc into aowow_' . $tableName);
$dbc = new DBC($tbl[0], CLISetup::$tmpDBC);
if ($dbc->error) {
return false;
}
$dbcData = $dbc->readArbitrary($tbl[1]);
foreach ($dbcData as $row) {
DB::Aowow()->query('REPLACE INTO ?_' . $tableName . ' (?#) VALUES (?a)', array_keys($row), array_values($row));
}
return !!$dbcData;
} else {
if (file_exists('setup/tools/sqlgen/' . $tableName . '.func.php')) {
$customData = $reqDBC = [];
CLISetup::log('SqlGen::generate() - filling aowow_' . $tableName . ' with data');
require_once 'setup/tools/sqlgen/' . $tableName . '.func.php';
if (function_exists($tableName)) {
// check for required auxiliary DBC files
foreach ($reqDBC as $req) {
if (!CLISetup::loadDBC($req)) {
return false;
}
}
$success = $tableName($updateIds);
// apply post generator custom data
foreach ($customData as $id => $data) {
if ($data) {
DB::Aowow()->query('UPDATE ?_' . $tableName . ' SET ?a WHERE id = ?d', $data, $id);
}
}
} else {
CLISetup::log(' - subscript \'' . $tableName . '\' not defined in included file', CLISetup::LOG_ERROR);
}
return $success;
} else {
CLISetup::log(sprintf(ERR_MISSING_INCL, $tableName, 'setup/tools/sqlgen/' . $tableName . '.func.php'), CLISetup::LOG_ERROR);
}
}
}
示例2: generate
public static function generate($key, array $updateIds = [])
{
$success = false;
$reqDBC = [];
if (file_exists('setup/tools/filegen/' . $key . '.func.php')) {
require_once 'setup/tools/filegen/' . $key . '.func.php';
} else {
if (empty(self::$tplFiles[$key])) {
CLISetup::log(sprintf(ERR_MISSING_INCL, $key, 'setup/tools/filegen/' . $key . '.func.php', CLISetup::LOG_ERROR));
return false;
}
}
CLISetup::log('FileGen::generate() - gathering data for ' . $key);
if (!empty(self::$tplFiles[$key])) {
list($file, $destPath, $deps) = self::$tplFiles[$key];
if ($content = file_get_contents(FileGen::$tplPath . $file . '.in')) {
if ($dest = @fOpen($destPath . $file, "w")) {
// replace constants
$content = strtr($content, FileGen::$txtConstants);
// check for required auxiliary DBC files
foreach ($reqDBC as $req) {
if (!CLISetup::loadDBC($req)) {
continue 2;
}
}
// must generate content
// PH format: /*setup:<setupFunc>*/
$funcOK = true;
if (preg_match_all('/\\/\\*setup:([\\w\\-_]+)\\*\\//i', $content, $m)) {
foreach ($m[1] as $func) {
if (function_exists($func)) {
$content = str_replace('/*setup:' . $func . '*/', $func(), $content);
} else {
$funcOK = false;
CLISetup::log('No function for was registered for placeholder ' . $func . '().', CLISetup::LOG_ERROR);
if (!array_reduce(get_included_files(), function ($inArray, $itr) use($func) {
return $inArray || false !== strpos($itr, $func);
}, false)) {
CLISetup::log('Also, expected include setup/tools/filegen/' . $name . '.func.php was not found.');
}
}
}
}
if (fWrite($dest, $content)) {
CLISetup::log(sprintf(ERR_NONE, CLISetup::bold($destPath . $file)), CLISetup::LOG_OK);
if ($content && $funcOK) {
$success = true;
}
} else {
CLISetup::log(sprintf(ERR_WRITE_FILE, CLISetup::bold($destPath . $file)), CLISetup::LOG_ERROR);
}
fClose($dest);
} else {
CLISetup::log(sprintf(ERR_CREATE_FILE, CLISetup::bold($destPath . $file)), CLISetup::LOG_ERROR);
}
} else {
CLISetup::log(sprintf(ERR_READ_FILE, CLISetup::bold(FileGen::$tplPath . $file . '.in')), CLISetup::LOG_ERROR);
}
} else {
if (!empty(self::$datasets[$key])) {
if (function_exists($key)) {
// check for required auxiliary DBC files
foreach ($reqDBC as $req) {
if (!CLISetup::loadDBC($req)) {
return false;
}
}
$success = $key($updateIds);
} else {
CLISetup::log(' - subscript \'' . $key . '\' not defined in included file', CLISetup::LOG_ERROR);
}
}
}
set_time_limit(FileGen::$defaultExecTime);
// reset to default for the next script
return $success;
}