Code Monkey home page Code Monkey logo

Comments (16)

egorio avatar egorio commented on June 17, 2024 11

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.

cebe avatar cebe commented on June 17, 2024 10

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.

creocoder avatar creocoder commented on June 17, 2024 2

@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.

Faryshta avatar Faryshta commented on June 17, 2024 1

findAll and findOne are very closely related. Should findOne behavior change to work without $condition too? and return ActiveRecord::find()->one() ?

from active-record.

cebe avatar cebe commented on June 17, 2024

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.

cebe avatar cebe commented on June 17, 2024

@creocoder I was already convinced ;)

from active-record.

vkarelin avatar vkarelin commented on June 17, 2024

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.

cebe avatar cebe commented on June 17, 2024

active query can, but not the findAll() shortcut. You can speed things up by sending a PR.

from active-record.

hellvesper avatar hellvesper commented on June 17, 2024

If findAll() shortcut for find()->all() they need to be similar or this illogically

from active-record.

shahidkarimi avatar shahidkarimi commented on June 17, 2024

I NEED THIS findAll() IN ANY CASE. HOW CAN I DO THIS?

from active-record.

SilverFire avatar SilverFire commented on June 17, 2024

There is an active pull request that will be merged in 2.1 branch.

from active-record.

longrunningprocess avatar longrunningprocess commented on June 17, 2024

@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.

eisdevelopers avatar eisdevelopers commented on June 17, 2024

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.

LazyKnightX avatar LazyKnightX commented on June 17, 2024

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.

samdark avatar samdark commented on June 17, 2024

It's ready for adoption in 2.1. Feel free to implement it and send a pull request.

from active-record.

YanAlex avatar YanAlex commented on June 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.