loading...

re: Handling complex MVC applications - How to scale and avoid Controller chaos VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I dont want to be "that guy" but... usually when we talk about scale-ability, its in terms of load balancing etc. What you're referencing is main...
 

However, just to provide some code examples in Laravel.

An unscalable chunk of code(in my opinion) would be this:


$users = User::get();

foreach($users as $user) {
    $user->name = 'Bob'; // We set them all the same name for example
    $user->save(); //This would be a query for each user
}

If we had 100 users, this would be 101 queries.


//Instead, for this example, we could just call this:

User::update(['name' => 'bob']); 

Resulting in just one query.

code of conduct - report abuse