Download the PHP package sllhsmile/wherehasin without Composer

On this page you can find all versions of the php package sllhsmile/wherehasin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wherehasin

# Hyperf WHERE HAS IN

Build Status

Hyperf wherehasin是一个使用 IN 子查询优化关联过滤的 Hyperf ORM 扩展包,适用于 Hyperf 3.0+ 和 PHP 8.1+。

whereHasIn 与原生 whereHas 的执行计划不同。仅在已评估索引与数据分布、确实需要 IN 子查询时使用;关联回调可以添加筛选条件,但其 select() 不会改变扩展为关联键生成的单列子查询。

环境

安装

简介

Hyperf的关联关系查询whereHas在日常开发中给我们带来了极大的便利,但是在主表数据量比较多的时候会有比较严重的性能问题,主要是因为whereHas用了where exists (select * ...)这种方式去查询关联数据。

通过这个扩展包提供的whereHasIn方法,可以把语句转化为where id in (select xxx.id ...)的形式,从而提高查询性能,下面我们来做一个简单的对比:

当主表数据量较多的情况下,where id in会有明显的性能提升;当主表数据量较少的时候,两者性能相差无几。

主表test_users写入130002条数据,关联表test_user_profiles写入1002条数据,查询代码如下

最终耗时如下,可以看出性能相差还是不小的,如果数据量更多一些,这个差距还会更大

使用

whereHasIn

此方法已支持Hyperf ORM中的所有关联关系,可以替代whereHas

orWhereHasIn

多级关联关系

需要注意的是,如果是BelongsTo类型的关联关系,使用whereHasIn时使用的不是主键,而是外键

whereHasMorphIn

此方法已支持Hyperf ORM中的所有关联关系,可以替代whereHasMorph

测试

安装开发依赖后执行:

集成测试默认跳过真实数据库。要验证跨连接关系、回调 select() 和通配 Morph 的 NULL 类型处理,可在本地 MySQL 上显式运行:

测试仅创建并在结束时删除 wherehasin_test_* 临时表。

特别鸣谢 https://github.com/jqhph/laravel-wherehasin

License

The MIT License (MIT).


All versions of wherehasin with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
hyperf/config Version ^3.0@dev
hyperf/database Version ^3.0@dev
hyperf/stringable Version ^3.0@dev
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sllhsmile/wherehasin contains the following files

Loading the files please wait ...