function DatabaseDeleteTruncateTestCase::testTruncate
Confirm that we can truncate a whole table successfully.
File
-
modules/
simpletest/ tests/ database_test.test, line 1202
Class
- DatabaseDeleteTruncateTestCase
- Delete/Truncate tests.
Code
function testTruncate() {
$num_records_before = db_query("SELECT COUNT(*) FROM {test}")->fetchField();
db_truncate('test')->execute();
$num_records_after = db_query("SELECT COUNT(*) FROM {test}")->fetchField();
$this->assertEqual(0, $num_records_after, 'Truncate really deletes everything.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.