countTableRows example

/** * Confirms that temporary tables work. */
  public function testTemporaryQuery() {
    $connection = $this->getConnection();

    // Now try to run two temporary queries in the same request.     $table_name_test = $connection->queryTemporary('SELECT [name] FROM {test}', []);
    $table_name_task = $connection->queryTemporary('SELECT [pid] FROM {test_task}', []);

    $this->assertEquals($this->countTableRows('test')$this->countTableRows($table_name_test), 'A temporary table was created successfully in this request.');
    $this->assertEquals($this->countTableRows('test_task')$this->countTableRows($table_name_task), 'A second temporary table was created successfully in this request.');

    // Check that leading whitespace and comments do not cause problems     // in the modified query.     $sql = " -- Let's select some rows into a temporary table SELECT [name] FROM {test} ";
    $table_name_test = $connection->queryTemporary($sql[]);
    $this->assertEquals($this->countTableRows('test')$this->countTableRows($table_name_test), 'Leading white space and comments do not interfere with temporary table creation.');
  }

}
Home | Imprint | This part of the site doesn't use cookies.