当前位置: 首页>>代码示例>>PHP>>正文


PHP db_truncate函数代码示例

本文整理汇总了PHP中db_truncate函数的典型用法代码示例。如果您正苦于以下问题:PHP db_truncate函数的具体用法?PHP db_truncate怎么用?PHP db_truncate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了db_truncate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFiles

 /**
  * Tests the Drupal 6 files to Drupal 8 migration.
  */
 public function testFiles()
 {
     /** @var \Drupal\file\FileInterface $file */
     $file = entity_load('file', 1);
     $this->assertIdentical('Image1.png', $file->getFilename());
     $this->assertIdentical('39325', $file->getSize());
     $this->assertIdentical('public://image-1.png', $file->getFileUri());
     $this->assertIdentical('image/png', $file->getMimeType());
     // It is pointless to run the second half from MigrateDrupal6Test.
     if (empty($this->standalone)) {
         return;
     }
     // Test that we can re-import and also test with file_directory_path set.
     db_truncate(entity_load('migration', 'd6_file')->getIdMap()->mapTableName())->execute();
     $migration = entity_load_unchanged('migration', 'd6_file');
     $dumps = array($this->getDumpDirectory() . '/Variable.php');
     $this->prepare($migration, $dumps);
     // Update the file_directory_path.
     Database::getConnection('default', 'migrate')->update('variable')->fields(array('value' => serialize('files/test')))->condition('name', 'file_directory_path')->execute();
     Database::getConnection('default', 'migrate')->update('variable')->fields(array('value' => serialize($this->getTempFilesDirectory())))->condition('name', 'file_directory_temp')->execute();
     $executable = new MigrateExecutable($migration, $this);
     $executable->import();
     $file = entity_load('file', 2);
     $this->assertIdentical('public://core/modules/simpletest/files/image-2.jpg', $file->getFileUri());
     // Ensure that a temporary file has been migrated.
     $file = entity_load('file', 6);
     $this->assertIdentical('temporary://' . static::getUniqueFilename(), $file->getFileUri());
 }
开发者ID:dev981,项目名称:gaptest,代码行数:31,代码来源:MigrateFileTest.php

示例2: clear

 public function clear($cid = NULL, $wildcard = FALSE)
 {
     if (empty($cid) || $wildcard && $cid == '*') {
         db_truncate('dc_api_product')->execute();
         return;
     }
     $org_op = $prod_op = '=';
     if ($wildcard) {
         if (strpos($cid, ':') !== FALSE) {
             list($orgName, $productName) = explode(':', $cid, 2);
         } else {
             $orgName = $cid;
             $productName = '*';
         }
         if (strpos($orgName, '*') !== FALSE) {
             $orgName = str_replace('*', '%', $orgName);
             $org_op = 'LIKE';
         }
         if (strpos($productName, '*') !== FALSE) {
             $productName = str_replace('*', '%', $productName);
             $prod_op = 'LIKE';
         }
     } else {
         list($orgName, $productName) = @explode(':', $cid, 2);
     }
     db_delete('dc_api_product')->condition('org_name', $orgName, $org_op)->condition('name', $productName, $prod_op)->execute();
 }
开发者ID:nevetS,项目名称:flame,代码行数:27,代码来源:ApiProductCache.php

示例3: testTruncate

 /**
  * Confirms that we can truncate a whole table successfully.
  */
 function testTruncate()
 {
     $num_records_before = db_query("SELECT COUNT(*) FROM {test}")->fetchField();
     $this->assertTrue($num_records_before > 0, 'The table is not empty.');
     db_truncate('test')->execute();
     $num_records_after = db_query("SELECT COUNT(*) FROM {test}")->fetchField();
     $this->assertEqual(0, $num_records_after, 'Truncate really deletes everything.');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:11,代码来源:DeleteTruncateTest.php

示例4: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     /** @var \Drupal\migrate\entity\Migration $migration */
     $migration = entity_load('migration', 'd6_node');
     $executable = new MigrateExecutable($migration, $this);
     $executable->import();
     // This is required for the second import below.
     db_truncate($migration->getIdMap()->mapTableName())->execute();
     $this->standalone = TRUE;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:14,代码来源:MigrateNodeTest.php

示例5: testMenu

 /**
  * Tests the Drupal 6 menu to Drupal 8 migration.
  */
 public function testMenu()
 {
     $navigation_menu = entity_load('menu', 'navigation');
     $this->assertEqual($navigation_menu->id(), 'navigation');
     $this->assertEqual($navigation_menu->label(), 'Navigation');
     $this->assertEqual($navigation_menu->description, 'The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.');
     // Test that we can re-import using the ConfigEntityBase destination.
     Database::getConnection('default', 'migrate')->update('menu_custom')->fields(array('title' => 'Home Navigation'))->condition('menu_name', 'navigation')->execute();
     db_truncate(entity_load('migration', 'd6_menu')->getIdMap()->mapTableName())->execute();
     $migration = entity_load_unchanged('migration', 'd6_menu');
     $executable = new MigrateExecutable($migration, $this);
     $executable->import();
     $navigation_menu = entity_load_unchanged('menu', 'navigation');
     $this->assertEqual($navigation_menu->label(), 'Home Navigation');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:18,代码来源:MigrateMenuTest.php

示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create Basic page node type.
     if ($this->profile != 'standard') {
         $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
     }
     $this->authUser = $this->drupalCreateUser(array('access content', 'create page content', 'edit own page content'));
     // Ensure we have a node page to access.
     $this->node = $this->drupalCreateNode(array('title' => $this->randomMachineName(255), 'uid' => $this->authUser->id()));
     // Enable access logging.
     $this->config('statistics.settings')->set('count_content_views', 1)->save();
     // Clear the logs.
     db_truncate('node_counter');
     $this->client = \Drupal::service('http_client_factory')->fromOptions(['config/curl' => [CURLOPT_TIMEOUT => 10]]);
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:16,代码来源:StatisticsLoggingTest.php

示例7: testMenu

    /**
     * Tests the Drupal 6 menu to Drupal 8 migration.
     */
    public function testMenu()
    {
        $navigation_menu = Menu::load('navigation');
        $this->assertIdentical('navigation', $navigation_menu->id());
        $this->assertIdentical('Navigation', $navigation_menu->label());
        $expected = <<<EOT
The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.
EOT;
        $this->assertIdentical($expected, $navigation_menu->getDescription());
        // Test that we can re-import using the ConfigEntityBase destination.
        Database::getConnection('default', 'migrate')->update('menu_custom')->fields(array('title' => 'Home Navigation'))->condition('menu_name', 'navigation')->execute();
        $migration = Migration::load('menu');
        db_truncate($migration->getIdMap()->mapTableName())->execute();
        $this->executeMigration($migration);
        $navigation_menu = Menu::load('navigation');
        $this->assertIdentical('Home Navigation', $navigation_menu->label());
    }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:20,代码来源:MigrateMenuTest.php

示例8: testDateFormats

 /**
  * Tests the Drupal 6 date formats to Drupal 8 migration.
  */
 public function testDateFormats()
 {
     $short_date_format = entity_load('date_format', 'short');
     $this->assertIdentical('\\S\\H\\O\\R\\T m/d/Y - H:i', $short_date_format->getPattern());
     $medium_date_format = entity_load('date_format', 'medium');
     $this->assertIdentical('\\M\\E\\D\\I\\U\\M D, m/d/Y - H:i', $medium_date_format->getPattern());
     $long_date_format = entity_load('date_format', 'long');
     $this->assertIdentical('\\L\\O\\N\\G l, F j, Y - H:i', $long_date_format->getPattern());
     // Test that we can re-import using the EntityDateFormat destination.
     Database::getConnection('default', 'migrate')->update('variable')->fields(array('value' => serialize('\\S\\H\\O\\R\\T d/m/Y - H:i')))->condition('name', 'date_format_short')->execute();
     db_truncate(entity_load('migration', 'd6_date_formats')->getIdMap()->mapTableName())->execute();
     $migration = entity_load_unchanged('migration', 'd6_date_formats');
     $executable = new MigrateExecutable($migration, $this);
     $executable->import();
     $short_date_format = entity_load('date_format', 'short');
     $this->assertIdentical('\\S\\H\\O\\R\\T d/m/Y - H:i', $short_date_format->getPattern());
 }
开发者ID:scratch,项目名称:gai,代码行数:20,代码来源:MigrateDateFormatTest.php

示例9: testFiles

 /**
  * Tests the Drupal 6 files to Drupal 8 migration.
  */
 public function testFiles()
 {
     /** @var \Drupal\file\FileInterface $file */
     $file = entity_load('file', 1);
     $this->assertEqual($file->getFilename(), 'Image1.png');
     $this->assertEqual($file->getSize(), 39325);
     $this->assertEqual($file->getFileUri(), 'public://image-1.png');
     $this->assertEqual($file->getMimeType(), 'image/png');
     // It is pointless to run the second half from MigrateDrupal6Test.
     if (empty($this->standalone)) {
         return;
     }
     // Test that we can re-import and also test with file_directory_path set.
     db_truncate(entity_load('migration', 'd6_file')->getIdMap()->mapTableName())->execute();
     $migration = entity_load_unchanged('migration', 'd6_file');
     $dumps = array($this->getDumpDirectory() . '/Drupal6SystemFile.php');
     $this->loadDumps($dumps, 'loadMigrateFileStandalone');
     $executable = new MigrateExecutable($migration, $this);
     $executable->import();
     $file = entity_load('file', 2);
     $this->assertEqual($file->getFileUri(), 'public://core/modules/simpletest/files/image-2.jpg');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:25,代码来源:MigrateFileTest.php

示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create Basic page node type.
     if ($this->profile != 'standard') {
         $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
     }
     $this->authUser = $this->drupalCreateUser(array('access content', 'create page content', 'edit own page content', 'administer languages', 'access administration pages'));
     // Ensure we have a node page to access.
     $this->node = $this->drupalCreateNode(array('title' => $this->randomMachineName(255), 'uid' => $this->authUser->id()));
     // Add a custom language and enable path-based language negotiation.
     $this->drupalLogin($this->authUser);
     $this->language = array('predefined_langcode' => 'custom', 'langcode' => 'xx', 'label' => $this->randomMachineName(16), 'direction' => 'ltr');
     $this->drupalPostForm('admin/config/regional/language/add', $this->language, t('Add custom language'));
     $this->drupalPostForm('admin/config/regional/language/detection', array('language_interface[enabled][language-url]' => 1), t('Save settings'));
     $this->drupalLogout();
     // Enable access logging.
     $this->config('statistics.settings')->set('count_content_views', 1)->save();
     // Clear the logs.
     db_truncate('node_counter');
     $this->client = \Drupal::service('http_client_factory')->fromOptions(['config/curl' => [CURLOPT_TIMEOUT => 10]]);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:22,代码来源:StatisticsLoggingTest.php

示例11: clearWatchdog

 /**
  * Clears watchdog messages.
  */
 public function clearWatchdog()
 {
     db_truncate('watchdog')->execute();
 }
开发者ID:jorgegc,项目名称:behat-drupal-extension,代码行数:7,代码来源:WatchdogContext.php

示例12: disassociateAllNodes

 public static function disassociateAllNodes()
 {
     db_truncate('lingotek');
 }
开发者ID:bunnywong,项目名称:isnatura.com.hk,代码行数:4,代码来源:LingotekSync.php

示例13: save_sitemap

 /**
  * Saves the sitemap to the db.
  */
 private function save_sitemap()
 {
     db_truncate('simplesitemap')->execute();
     $values = array();
     foreach ($this->sitemap as $chunk_id => $chunk_data) {
         $values[] = array('id' => $chunk_id, 'sitemap_string' => $chunk_data->sitemap_string, 'sitemap_created' => $chunk_data->sitemap_created);
     }
     $query = db_insert('simplesitemap')->fields(array('id', 'sitemap_string', 'sitemap_created'));
     foreach ($values as $record) {
         $query->values($record);
     }
     $query->execute();
 }
开发者ID:k-zafar,项目名称:barney_river,代码行数:16,代码来源:Simplesitemap.php

示例14: disassociateAllChunks

 public static function disassociateAllChunks()
 {
     db_truncate('{lingotek_config_metadata}')->execute();
 }
开发者ID:kweigand,项目名称:cck,代码行数:4,代码来源:LingotekSync.php

示例15: testThresholdNotify

 /**
  * Test threshold notify functionality.
  */
 public function testThresholdNotify()
 {
     // Set notify threshold to 5, and user locking to 5.
     \Drupal::configFactory()->getEditable('login_security.settings')->set('user_wrong_count', 5)->set('activity_threshold', 5)->save();
     // Attempt 10 bad logins. Since the user will be locked out after 5, only
     // a single log message should be set, and an attack should not be
     // detected.
     for ($i = 0; $i < 10; $i++) {
         $login = ['name' => $this->badUsers[0]->getUsername(), 'pass' => 'bad_password_' . $i];
         $this->drupalPostForm('user', $login, t('Log in'));
     }
     // Ensure a log message has been set.
     $logs = $this->getLogMessages();
     $this->assertEqual(count($logs), 1, '1 event was logged.');
     $log = array_pop($logs);
     $this->assertBlockedUser($log, $this->badUsers[0]->getUsername());
     db_truncate('watchdog')->execute();
     // Run failed logins as second user to trigger an attack warning.
     for ($i = 0; $i < 10; $i++) {
         $login = ['name' => $this->badUsers[1]->getUsername(), 'pass' => 'bad_password_' . $i];
         $this->drupalPostForm('user', $login, t('Log in'));
     }
     $logs = $this->getLogMessages();
     // 2 logs should be generated.
     $this->assertEqual(count($logs), 2, '2 events were logged.');
     // First log should be the ongoing attack, triggered on attempt after the
     // threshold.
     $log = array_shift($logs);
     $variables = ['@activity_threshold' => 5, '@tracking_current_count' => 6];
     $expected = SafeMarkup::format('Ongoing attack detected: Suspicious activity detected in login form submissions. Too many invalid login attempts threshold reached: currently @tracking_current_count events are tracked, and threshold is configured for @activity_threshold attempts.', $variables);
     $this->assertEqual(SafeMarkup::format($log->message, unserialize($log->variables)), $expected);
     $this->assertEqual($log->severity, RfcLogLevel::WARNING, 'The logged alert was of severity "Warning".');
     // Second log should be a blocked user.
     $log = array_shift($logs);
     $this->assertBlockedUser($log, $this->badUsers[1]->getUsername());
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:39,代码来源:LoginSecurityUserBlockingTest.php


注:本文中的db_truncate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。