查询语言.reset

Testing Is Documentation

tests/Database/Query/ResetTest.php查询语言.reset - 图1

Uses

  1. <?php
  2. use Tests\Database\DatabaseTestCase as TestCase;

重置所有

  1. public function testBaseUse(): void
  2. {
  3. $connect = $this->createDatabaseConnectMock();
  4. $sql = <<<'eot'
  5. [
  6. "SELECT `test_query_subsql`.* FROM `test_query_subsql` WHERE `test_query_subsql`.`new` = :test_query_subsql_new",
  7. {
  8. "test_query_subsql_new": [
  9. "world"
  10. ]
  11. },
  12. false
  13. ]
  14. eot;
  15. $this->assertSame(
  16. $sql,
  17. $this->varJson(
  18. $connect
  19. ->table('test_query')
  20. ->where('id', '=', 5)
  21. ->where('name', 'like', 'me')
  22. ->reset()
  23. ->table('test_query_subsql')
  24. ->where('new', '=', 'world')
  25. ->findAll(true)
  26. )
  27. );
  28. }

重置某一项

  1. public function testResetItem(): void
  2. {
  3. $connect = $this->createDatabaseConnectMock();
  4. $sql = <<<'eot'
  5. [
  6. "SELECT `test_query`.`name`,`test_query`.`id` FROM `test_query` WHERE `test_query`.`new` LIKE :test_query_new",
  7. {
  8. "test_query_new": [
  9. "new"
  10. ]
  11. },
  12. false
  13. ]
  14. eot;
  15. $this->assertSame(
  16. $sql,
  17. $this->varJson(
  18. $connect
  19. ->table('test_query')
  20. ->where('id', '=', 5)
  21. ->where('name', 'like', 'me')
  22. ->setColumns('name,id')
  23. ->reset('where')
  24. ->where('new', 'like', 'new')
  25. ->findAll(true),
  26. 1
  27. )
  28. );
  29. }