本文整理汇总了PHP中D::clear_cache方法的典型用法代码示例。如果您正苦于以下问题:PHP D::clear_cache方法的具体用法?PHP D::clear_cache怎么用?PHP D::clear_cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类D
的用法示例。
在下文中一共展示了D::clear_cache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sync
/**
* Checks for differences in mapping information compared to the database, and creates a migration if there are any
*
* @param string $name Name of module or package, unless this is just an 'app' migration
* @param string $type Type of migration - 'app', 'module' or 'package'
* @return void
*/
public static function sync($name = 'default', $type = 'app', $run = false, $reset = false)
{
try {
set_time_limit(0);
ignore_user_abort(true);
ini_set('memory_limit', '256M');
} catch (\Exception $e) {
// Nothing!
}
\Config::load("db", true, true);
\D::$clear_cache = true;
$em = \D::manager();
$files = glob(APPPATH . "migrations/*_*.php");
if ($reset) {
$files[] = APPPATH . 'config/development/migrations.php';
$files[] = APPPATH . 'config/production/migrations.php';
$files[] = APPPATH . 'config/staging/migrations.php';
foreach ($files as $file) {
try {
\File::delete($file);
} catch (\Exception $e) {
}
}
$files = array();
\Config::load('migrations', true, true);
}
// This will create the migrations table if necessary
Migrate::_init();
$last_file = end($files);
if ($last_file) {
// Try and find the last file migration in the DB
$last_name = basename($last_file, ".php");
$migration_table = \Config::get('migrations.table', 'migration');
$last_migration = \DB::query("SELECT migration FROM {$migration_table} WHERE type = '{$type}' AND name = '{$name}' AND migration = '{$last_name}'")->execute();
if (count($last_migration) === 0) {
if (\Fuel::$is_cli && \Cli::prompt('You have previous migrations to run - you must run these before generating a new one. Continue?', array('y', 'n')) == 'y') {
\Cli::write("\tRunning previous migrations...", 'green');
Migrate::latest($name, $type);
} else {
return array('error' => 'There are previous migrations to run - please do this first before syncing.');
}
}
}
$diff = static::getDiff();
if (array_key_exists('error', $diff)) {
if (\Fuel::$is_cli) {
\Cli::write($diff['error'], 'red');
return;
} else {
return $diff;
}
}
static::generateMigration($diff['up'], $diff['down']);
if (\Fuel::$is_cli && ($run === true || \Cli::prompt('Would you like to run the new migration now?', array('y', 'n')) == 'y') || !\Fuel::$is_cli && $run) {
Migrate::latest($name, $type);
static::createAllStaticInstances();
}
return array('success' => 'The sync was completed and all migrations performed successfully');
}