Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/06/2022 in all areas

  1. Depending on what it is you're trying to do with the data, there are several ways to change a field. You can set up an accessor or mutator or use a query scope, for instance. Query scope sounds like what you're looking for, although should worse comes to worst you could just write a trait and use it on your model instances where needed.
    2 points
  2. The error message tells you the query failed. Try adding a space after "LIMIT" $getQuery = "SELECT * FROM games LIMIT $initial_page, $limit";
    1 point
  3. I have recreated your attendance table and have run your code. I now know what you don't want. (109 columns labelled "31-May") Perhaps you could tell us what you do want?
    1 point
  4. What is the real question you are asking? PHP code in a PHP application is one component, loop or no loop. So it seems your real question is: 1 Query (with a join) vs. Multiple queries. 1 Query will always be faster and more efficient than multiple, unless there is something very wrong/unoptimized with the query. With that said, when you have static related tables, then having those tables cached can save you having to join the tables or do queries in a loop. As the result set will have to be "hydrated/expanded" within your PHP script to make use of those, or at least resolve the values you need from the cached lookup table, the complexity of adding all that code isn't often worth the pain, and might not even be more efficient in the long run, given a PHP script's short lifespan. What is certainly worth looking at, is the addition of a relational result cache like memcached or redis.
    1 point
  5. Most of these are named in a way that is fairly self explanatory, but sometimes you have to just take a look at the class to see what it is doing. \App\Http\Middleware\TrustProxies::class -> https://laravel.com/docs/9.x/requests#configuring-trusted-proxies (If you are using a proxy server or load balancer, this handles certain issues that arise) \Fruitcake\Cors\HandleCors::class -> https://github.com/fruitcake/laravel-cors (Configure your framework to set certain CORS related HTTP Headers) \App\Http\Middleware\PreventRequestsDuringMaintenance::class -> https://laravel.com/docs/9.x/configuration (See how to turn on Maintenance mode using artisan. Once it's turned on, this middleware enforces it) \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class -> See source https://github.com/laravel/framework/blob/5.8/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php (Notice that code just checks the configured PHP post_max_size against the size of an HTTP Post request. If the post request is too large, laravel throws a PostTooLarge exception.) The last 2 are again, very similar. Looking at the class definitions from the manual will show you what they do, and the code is simple and self explanatory, especially once you understand the things I explained about how middleware works in Laravel. See https://laravel.com/api/9.x/index.html and find the 2 classes.
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.