本文整理汇总了PHP中SilverStripe\ORM\DB::alteration_message方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::alteration_message方法的具体用法?PHP DB::alteration_message怎么用?PHP DB::alteration_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SilverStripe\ORM\DB
的用法示例。
在下文中一共展示了DB::alteration_message方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($request)
{
$migrated = FileMigrationHelper::singleton()->run();
if ($migrated) {
DB::alteration_message("{$migrated} File DataObjects upgraded", "changed");
} else {
DB::alteration_message("No File DataObjects need upgrading", "notice");
}
}
示例2: requireDefaultRecords
/**
* Add default records to database. This function is called whenever the
* database is built, after the database tables have all been created. Overload
* this to add default records when the database is built, but make sure you
* call parent::requireDefaultRecords().
*
* @uses DataExtension->requireDefaultRecords()
*/
public function requireDefaultRecords()
{
$defaultRecords = $this->stat('default_records');
if (!empty($defaultRecords)) {
$hasData = DataObject::get_one($this->class);
if (!$hasData) {
$className = $this->class;
foreach ($defaultRecords as $record) {
$obj = $this->model->{$className}->newObject($record);
$obj->write();
}
DB::alteration_message("Added default records to {$className} table", "created");
}
}
// Let any extentions make their own database default data
$this->extend('requireDefaultRecords', $dummy);
}
示例3: requireDefaultRecords
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
// Check if old file records should be migrated
if (!$this->config()->migrate_legacy_file) {
return;
}
$migrated = FileMigrationHelper::singleton()->run();
if ($migrated) {
DB::alteration_message("{$migrated} File DataObjects upgraded", "changed");
}
}
示例4: cleanupVersionedOrphans
/**
* Cleanup orphaned records in the _versions table
*
* @param string $baseTable base table to use as authoritative source of records
* @param string $childTable Sub-table to clean orphans from
*/
protected function cleanupVersionedOrphans($baseTable, $childTable)
{
// Skip if child table doesn't exist
if (!DB::get_schema()->hasTable($childTable)) {
return;
}
// Skip if tables are the same
if ($childTable === $baseTable) {
return;
}
// Select all orphaned version records
$orphanedQuery = SQLSelect::create()->selectField("\"{$childTable}\".\"ID\"")->setFrom("\"{$childTable}\"");
// If we have a parent table limit orphaned records
// to only those that exist in this
if (DB::get_schema()->hasTable($baseTable)) {
$orphanedQuery->addLeftJoin($baseTable, "\"{$childTable}\".\"RecordID\" = \"{$baseTable}\".\"RecordID\"\n\t\t\t\t\tAND \"{$childTable}\".\"Version\" = \"{$baseTable}\".\"Version\"")->addWhere("\"{$baseTable}\".\"ID\" IS NULL");
}
$count = $orphanedQuery->count();
if ($count > 0) {
DB::alteration_message("Removing {$count} orphaned versioned records", "deleted");
$ids = $orphanedQuery->execute()->column();
foreach ($ids as $id) {
DB::prepared_query("DELETE FROM \"{$childTable}\" WHERE \"ID\" = ?", array($id));
}
}
}