You are here

function SchemaTest::tryUnsignedInsert in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/src/Tests/Database/SchemaTest.php \Drupal\system\Tests\Database\SchemaTest::tryUnsignedInsert()

Tries to insert a negative value into columns defined as unsigned.

Parameters

$table_name: The table to insert.

$column_name: The column to insert.

Return value

TRUE if the insert succeeded, FALSE otherwise.

1 call to SchemaTest::tryUnsignedInsert()
SchemaTest::testUnsignedColumns in core/modules/system/src/Tests/Database/SchemaTest.php
Tests creating unsigned columns and data integrity thereof.

File

core/modules/system/src/Tests/Database/SchemaTest.php, line 462
Contains \Drupal\system\Tests\Database\SchemaTest.

Class

SchemaTest
Tests table creation and modification via the schema API.

Namespace

Drupal\system\Tests\Database

Code

function tryUnsignedInsert($table_name, $column_name) {
  try {
    db_insert($table_name)
      ->fields(array(
      $column_name => -1,
    ))
      ->execute();
    return TRUE;
  } catch (\Exception $e) {
    return FALSE;
  }
}