Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
AR documentation, pagination, security
  • Is there any documentation for the Active Records system? Does it support transaction too ? ORM is nice but it gets too many records. One-to-many would get a lot of rows with duplicate data, or is it using another smarter method? Like if I wanted a blog post and all its tags, would it return say if it had 10 tags it would return 10 rows all with copies of the blogpost ? or would it run two separate queries one for blogpost and 1 for all the tags and then merge the array? Same case if i wanted 5 blog posts each with 10 tags would it get 50 rows or run the two separate queries 1 to get all blog posts and one to get all tags and then merge them ?
    Also just wondering, does the pagination class work like it should? as in in CI it ads offset to the URL rather than page number. Does FuelPHP use page numbers or offsets? (the forum seems to be using offsets) Are inputs auto cleaned? or do I have to pass it thru the Security class each time? even URI segments?
    Thanks for any advice offered, I'm new to the DataMapper system so id appreciate any answers. It would be very useful to my project. DooPHP had a ORM but it does it the long way around so if FuelPHP does the same I will use AR.
  • My first suggestion would be to try and read the docs, there's a lot of answers in there already.
    Is there any documentation for the Active Records system? Does it support transaction too ? ORM is nice but it gets too many records. One-to-many would get a lot of rows with duplicate data, or is it using another smarter method?
    [..]
    Thanks for any advice offered, I'm new to the DataMapper system so id appreciate any answers. It would be very useful to my project. DooPHP had a ORM but it does it the long way around so if FuelPHP does the same I will use AR.
    First of all, did you actually check the docs - it's not complete but there's already documentation for a large chunk of the ORM. Second you get your terminology a bit mixed up: it is and we call the package "ORM", it's an interpretation of the ActiveRecord pattern, DataMapper is a whole other approach to an ORM. We don't call ours ActiveRecord though, just the Fuel ORM. Then to fetching duplicate data, what would be your approach? There's reason why you make the database do the heavy lifting in a request: that's what it's for. Database access is slow, but retrieval on its own is faster. Which is why you care more about fetching the right and complete information. If you know best: feel free to write your own and let's check your system's performance and flexibility against what we have here.
    Same case if i wanted 5 blog posts each with 10 tags would it get 50 rows or run the two separate queries 1 to get all blog posts and one to get all tags and then merge them ?
    Actually, if you prefer this: that's how php.ActiveRecord does it - which I have made available as a package for Fuel.
    Also just wondering, does the pagination class work like it should? as in in CI it ads offset to the URL rather than page number. Does FuelPHP use page numbers or offsets? (the forum seems to be using offsets)
    Why don't you, I just going to go out on a limb here, why don't you try if the docs have some info on this?
    Are inputs auto cleaned? or do I have to pass it thru the Security class each time? even URI segments?
    Fuel offers both input & output cleaning which can be configured in the app/config/config.php file. By default we have no input filter except for the Uri, but we do enable output encoding through the views by default. You can switch this around if you prefer.
  • I apologize if i have offended you regarding the documentation. I did read thru it a bit, but wasn't a 100% sure, my terminology is of-course probably wrong, since I'm really not familiar with DataMapper and ORM and the various terms it gets and how different frameworks approach it. When i looked thru the docs i found mostly on the main database system but there wasn't much details on JOINS and such so I was just curious which section that was documented on. As for the pagination, it would be helpful if the documentation had some example outcomes, but i guess i will try it myself and see if it shows numbers or offsets. I will read the docs again.
  • Hey, if you are curious how the Pagination works, look into this example: https://github.com/abdelm/stationwagon/blob/master/fuel/app/classes/controller/articles.php In general you can download/clone the stationwagon, it has lot's of things to look at, on how the things work etc Good luck :)
  • Jaroslav Petrusevic wrote on Tuesday 5th of April 2011:
    Hey, if you are curious how the Pagination works, look into this example: https://github.com/abdelm/stationwagon/blob/master/fuel/app/classes/controller/articles.php In general you can download/clone the stationwagon, it has lot's of things to look at, on how the things work etc Good luck :)

    Quite helpful! I noticed that profiler doesn't work though with the database though. Its shows 0 queries, even after its run them. =/ http://xdat.us/QlZWs.jpg http://xdat.us/dLzjQ.jpg Latest RC from this site, not git.
  • you are right here, profiler with DB isn't working yet... I think it should be ready before FuelPHP v1.0
  • try and check this patch: https://github.com/fuel/core/commit/fa3e3db7222176cba3ae367c381e00095ea4b428 could fix your problem with DB Queries profiling
  • Yes, I've fixed DB profiling in the develop and master branches based on this report, so it will be part of 1.0. For next time, please create a ticket on http://dev.fuelphp.com to make sure the bug is on our to-be-fixed list...
  • Harro Verton wrote on Wednesday 6th of April 2011:
    Yes, I've fixed DB profiling in the develop and master branches based on this report, so it will be part of 1.0. For next time, please create a ticket on http://dev.fuelphp.com to make sure the bug is on our to-be-fixed list...

    Sure ill report if i find anymore bugs. Btw, I have been looking but i cant find any documentation on using the ORM for joins. I have a Model_Lists and a Model_Music and im trying to get them to join using the ORM.
    class Model_Music extends Orm\Model {
    
        protected static $_table_name = 'mini_lists_music';
        protected static $_primary_key = array('list_id');
        protected static $_has_one = array(
            'lists' => array(
                'model_to'  => 'Model_Lists',
                'key_from'  => 'list_id',
                'key_to'    => 'list_id',
            ),
        );
    
    }
    
    Model_Anime::find('all');
    

    Doesn't do the join however, im just missing the right syntax for it.
  • New questions, new thread please.

Howdy, Stranger!

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

In this Discussion