laravel-wherehasin icon indicating copy to clipboard operation
laravel-wherehasin copied to clipboard

Laravel wherehasin是一个可以提升Laravel ORM关联关系查询性能的扩展包,可以替代Laravel ORM中的whereHas以及whereHasMorphIn查询方法。

Results 7 laravel-wherehasin issues
Sort by recently updated
recently updated
newest added

$q->from("{$databaseName}.{$table}"); 更改为 $q->fromRaw("{$databaseName}.{$prefix}{$table}"); 貌似兼容性更好 from多态关联whereHasMorphIn如果定义了表前缀可能产生错误的sql比如: select * from `lu_auth` where ((`lu_auth`.`lsc` = ? and `lu_auth`.`lid` in (select `lu_mate`.`id` from `lu_lu_db_qiaolu_idc`.`mate` where `lu_auth`.`lid` = `lu_mate`.`id` and `id` = ?)))

select * from `test_users` where `test_users`.`id` in ( select `test_user_profiles`.`user_id` from `test_user_profiles` where `test_users`.`id` = `test_user_profiles`.`user_id` ) 改成以下类型 select * from `test_users` where `test_users`.`id` in ( select `test_user_profiles`.`user_id` from `test_user_profiles`...

使用whereHasIn产生的语句 ``` select count(*) as aggregate from `users` where (`users`.`pid` in (select `users`.`id` from `users` where `users`.`pid` = `users`.`id` and `username` like '%test%')); ``` 使用whereHas产生的语句 ``` select count(*) as aggregate...

![image](https://user-images.githubusercontent.com/554917/124354334-17c80680-dc3e-11eb-827e-2f3784109f37.png) 劳烦 @jqhph 看看,感谢

whereHasIn('a.b') ![image](https://user-images.githubusercontent.com/54547557/91739909-26d8c500-ebe5-11ea-8453-ea7b00bce821.png) 实际的 .id 并非 模型中定义的 house_id 而用 whereHas ![image](https://user-images.githubusercontent.com/54547557/91740031-4e2f9200-ebe5-11ea-9325-39538f8ee2e9.png) 依然是按照 模型定义的 字段来查询的. 请大佬回复下.

![image](https://user-images.githubusercontent.com/29627681/91154956-c0d7d380-e6f4-11ea-8f01-7824fd1e5b35.png) 我一开始使用的whereHas闭包里面也是whereHas,数据正常。 今天替换了所有的whereHas为whereHasIn,发现在闭包里面用whereHasIn的结果是错误的(空)。 把闭包中的whereHasIn换成whereHas后正常了(如上图)。

![1](https://github.com/jqhph/laravel-wherehasin/assets/55525541/8e2151d7-273a-4395-bdf9-83d616c55f3f) ![2](https://github.com/jqhph/laravel-wherehasin/assets/55525541/8015f926-acfa-4648-b338-7d7a6277a499)