Comments (16)
If you have 10000 records and call findAll() you are crazy :)
You also can call find()->all() for this table. It is not a problem of code, it is problem of design :)
I told about small tables... for example $countries = Country::findAll();
from active-record.
What do you do if you have 10000 records in your database table? Fetching all records blindly is not a good idea when all get instantiated as active records...
from active-record.
@cebe Than crazyness prevention should go through whole system. You can still do for example MyModel::find()->all()
. I'm with OP. Condition should be removed. For example it just make pain to use findAll()
inside unit tests. When you really need find all records and compare with original data set.
from active-record.
findAll
and findOne
are very closely related. Should findOne
behavior change to work without $condition
too? and return ActiveRecord::find()->one()
?
from active-record.
I thought of the "design" that prevents crazyness by letting you think before you do findAll()
because it does not work ;) But you have a good point too.
from active-record.
@creocoder I was already convinced ;)
from active-record.
Hello!
Are there any advances in this issue?
Faced with the same problem and was surprised that AQ can not do query without conditions
from active-record.
active query can, but not the findAll() shortcut. You can speed things up by sending a PR.
from active-record.
If findAll() shortcut for find()->all() they need to be similar or this illogically
from active-record.
I NEED THIS findAll() IN ANY CASE. HOW CAN I DO THIS?
from active-record.
There is an active pull request that will be merged in 2.1 branch.
from active-record.
@shahidkarimi , not sure if checked #8200 yet but you can do ::find()->all()
for the same result until the PR is merged.
from active-record.
Hello,
::findAll( ) should be implemented. Hope it is already done by now. However, I see on 2.0.15 it is not available yet. But yes For tables with large data, the programmer has to use conditions. I am sure anyone working on large data would run proper queries to filter data.
from active-record.
As you guys said we should use find()->all()
as an alternative of findAll()
, is there any reason you do not check null param in findAll
and use find()->all()
for us?
Since findAll have nearly 100% same name with find()->all(), it's hard to understand why they do not have nearly 100% same feature.
If it is a problem of design, could you please explain this design? If it's a design, it should let us know that we should use find()->all() than findAll(), not just throw an inspection, without any hint comment in the original method (the original method comment tell us how to use with $condition, but not tell us that we should use find()->all() as an alternative).
+1 for findAll() without $condition
from active-record.
It's ready for adoption in 2.1. Feel free to implement it and send a pull request.
from active-record.
Is something better than?
namespace app\components\ar;
class ExtendedAr extends \yii\db\ActiveRecord
{
public static function findAll($condition = null)
{
return $condition ? parent::findAll($condition) : parent::find()->all();
}
}
from active-record.
Related Issues (20)
- `ActiveQuery` class should not extend `Yiisoft\Db\Query\Query` HOT 1
- Remove flag arguments from AR methods
- The method allPopulate in ActiveQuery will execute populate twice during execution
- PHPUnit 9.6.15 Warning - The configuration file did not pass validation!
- TableName() has no effect HOT 1
- update irc link
- The parameter identical of the method isAttributeChanged in class BaseActiveRecord has no effect when its value is false. HOT 2
- Yiiboot\ActiveRecord\ActiveRecord::populateRelation() not support the scalar type HOT 2
- Remove `psalm83.xml` after raising PHP version to `8.3`
- Summary for `ActiveRecord` HOT 4
- Realize `ReadOnlyActiveRecord` HOT 4
- Remove parameter `$throwException` from `ActiveRecordInterface::relationQuery()`
- Who can help me explain the current situation? HOT 2
- Rename `$attributes` to `$properties` HOT 4
- Implement `RepositoryInterface` and `RepositoryTrait` HOT 1
- Avoid `set` and `get` prefixes for methods
- Add `ArrangeBy` option HOT 1
- Support relations via `array` type columns HOT 3
- Allow pre- and post-processing values HOT 1
- Make AR constructor empty
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from active-record.