查询数据.find

Testing Is Documentation

tests/Database/Read/FindTest.php查询数据.find - 图1

Uses

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

find 查询基础用法

  1. public function testBaseUse(): void
  2. {
  3. $connect = $this->createDatabaseConnectMock();
  4. $sql = <<<'eot'
  5. [
  6. "SELECT `test`.* FROM `test`",
  7. [],
  8. false
  9. ]
  10. eot;
  11. $this->assertSame(
  12. $sql,
  13. $this->varJson(
  14. $connect
  15. ->sql()
  16. ->table('test')
  17. ->find()
  18. )
  19. );
  20. }

find 查询指定数量

  1. public function testFindLimit(): void
  2. {
  3. $connect = $this->createDatabaseConnectMock();
  4. $sql = <<<'eot'
  5. [
  6. "SELECT `test`.* FROM `test` LIMIT 0,5",
  7. [],
  8. false
  9. ]
  10. eot;
  11. $this->assertSame(
  12. $sql,
  13. $this->varJson(
  14. $connect
  15. ->sql()
  16. ->table('test')
  17. ->find(5),
  18. 1
  19. )
  20. );
  21. }