testTemporaryQuery example

/** * Tests the temporary query functionality. * * @group Database */
class TemporaryQueryTest extends TemporaryQueryTestBase {

  /** * Confirms that temporary tables work. */
  public function testTemporaryQuery() {
    parent::testTemporaryQuery();

    $connection = $this->getConnection();

    $table_name_test = $connection->queryTemporary('SELECT [name] FROM {test}', []);

    // Assert that the table is indeed a temporary one.     $this->stringContains("temp.", $table_name_test);

    // Assert that both have the same field names.     $normal_table_fields = $connection->query("SELECT * FROM {test}")->fetch();
    $temp_table_name = $connection->queryTemporary('SELECT * FROM {test}');
    
/** * Tests the temporary query functionality. * * @group Database */
class TemporaryQueryTest extends TemporaryQueryTestBase {

  /** * Confirms that temporary tables work. */
  public function testTemporaryQuery() {
    parent::testTemporaryQuery();

    $connection = $this->getConnection();

    $table_name_test = $connection->queryTemporary('SELECT [name] FROM {test}', []);

    // Assert that the table is indeed a temporary one.     $temporary_table_info = $connection->query("SELECT * FROM pg_class WHERE relname LIKE '%$table_name_test%'")->fetch();
    $this->assertEquals("t", $temporary_table_info->relpersistence);

    // Assert that both have the same field names.     $normal_table_fields = $connection->query("SELECT * FROM {test}")->fetch();
    
/** * Tests the temporary query functionality. * * @group Database */
class TemporaryQueryTest extends TemporaryQueryTestBase {

  /** * Confirms that temporary tables work. */
  public function testTemporaryQuery() {
    parent::testTemporaryQuery();

    $connection = $this->getConnection();

    $table_name_test = $connection->queryTemporary('SELECT [name] FROM {test}', []);

    // Assert that the table is indeed a temporary one.     $temporary_table_info = $connection->query("SHOW CREATE TABLE {" . $table_name_test . "}")->fetchAssoc();
    $this->stringContains($temporary_table_info["Create Table"], "CREATE TEMPORARY TABLE");

    // Assert that both have the same field names.     $normal_table_fields = $connection->query("SELECT * FROM {test}")->fetch();
    
Home | Imprint | This part of the site doesn't use cookies.