Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
php 7.4 Preloading
  • hi,
    PHP 7.4 comes with more features.
    One of these features is preloading
    Is there a plan to use preloading or other
    features?
    and:
    Is it there route cache?
    can i use "has many" order by some field (not found in document)?


  • HarroHarro
    Accepted Answer
    No, there is no plan to implement any PHP version specific features, Fuel v1 remains PHP 5.4+.

    No, there is no route cache. It has been looked at in the past, but the performance gain was minimal, and it killed all apps using dynamic routes (routes generated by code instead of defined in a config file).

    And I don't understand your last question. ORM? You can order by any field in the query.
  • HarroHarro
    Accepted Answer
    I have looked at the RFC for preloading, it looks to me like it is very simple to implement yourself, if you need it is needed.

    Note that there has not been any effort to look at 7.4 compatibility as of yet, it might be changes to the code are needed, there is no documentation yet with regards to backwards incompatibilities.
  • hi Harro.
    Well, if you just have a simple site, you can still use PHP 5.4 or html page.
    But for the sophisticated apps, there's a little different issue (I know thre is many of great apps exist with old versions of php like processmaker, ...)
    I currently use more than 200 sites with only one fuelphp backend.(I love the fuelphp)
    Speed and security are important to me and my customers.
    The main problem with this framework is probably to stick to the old version of php, which the developer gets less involved with.
    For preloading, the solution is simple, just as you mentioned(I'm testing it) .
    Advise for route cache if possible
    For the final question:
    $article = model_article::find(1);
    foreach($article->comments()->order_by('date','desc') as $rec){
    }
    thanks
  • What is comments() for method?

    If you mean that comments is a related object, you are using dynamic loading, you can't control that. Instead, you need to include the relation in the initial query, and you can order:

    $article = model_article::query()
      ->where('id', '=', 1)
      ->related('comments')
      ->order_by('comments.date', 'desc')
      ->get();

    You can also use the options array of find(), but I personally hate that syntax, I never use it. ;-)
  • article has many comments
    i get article and want to show comments:
    $main_record = model_main::find(1);
    foreach($main_record->has_many_name()->order_by('date','desc') as $rec){
    }
  • As I wrote, you can't do that with lazy loading, you need to include it in the query, like I showed.

    If you want to use find() and the options array, here's an example of how to do that:

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion