Error message
You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).function DatabaseInsertDefaultsTestCase::testDefaultInsertWithFields
Test that we can insert fields with values and defaults in the same query.
File
-
modules/
simpletest/ tests/ database_test.test, line 812
Class
- DatabaseInsertDefaultsTestCase
- Insert tests for "database default" values.
Code
function testDefaultInsertWithFields() {
$query = db_insert ('test')->fields (array(
'name' => 'Bob',
))
->useDefaults (array(
'job',
));
$id = $query->execute ();
$schema = drupal_get_schema ('test');
$job = db_query ('SELECT job FROM {test} WHERE id = :id', array(
':id' => $id,
))->fetchField ();
$this->assertEqual ($job, $schema['fields']['job']['default'], 'Default field value is set.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.