查询语言.prefix

Testing Is Documentation

tests/Database/Query/PrefixTest.php查询语言.prefix - 图1

Uses

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

prefix 基础用法

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

prefix 示例用法

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