查询构造器

QueryBuilder是一个SQL构造器,用来构造prepare sql。例如:

  1. use EasySwoole\Mysqli\QueryBuilder;
  2. $builder = new QueryBuilder();
  3. //执行条件构造逻辑
  4. $builder->where('col1',2)->get('my_table');
  5. //获取最后的查询参数
  6. echo $builder->getLastQueryOptions();
  7. //获取子查询
  8. echo $builder->getSubQuery();
  9. //获取上次条件构造的预处理sql语句
  10. echo $builder->getLastPrepareQuery();
  11. // SELECT * FROM whereGet WHERE col1 = ?
  12. //获取上次条件构造的预处理sql语句所以需要的绑定参数
  13. echo $builder->getLastBindParams();
  14. //[2]
  15. //获取上次条件构造的sql语句
  16. echo $builder->getLastQuery();
  17. //SELECT * FROM whereGet WHERE col1 = 2
  18. // 获取最后插入的insert_id 使用客户端从swoole mysql获取
  19. $client->mysqlClient()->insert_id