ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Gas ORM

October 23, 2011 4:00pm

Subscribe [45]
  • #226 / Mar 10, 2012 10:30am

    Khrome83

    22 posts

    When auto creating models, is there anything that is cached? I had a type-o in a column name in the Pivot table, but fixed it. Now every other relationship and model works well, with the exception of the table that had a type-o.

    When access contents of the table directly it works -

    $profs = Gas::factory('professions')->all();
    
       foreach($profs as $bar) {
        echo '
    
    ';
        echo 'Professions - '.$bar->name;
        //echo print_r($bar);
    
       }

    When accessing it through skills -

    $skills = Gas::factory('skills')->all();
    
       foreach($skills as $skill) {
        echo 'Skill Name Found - '.$skill->name;
        echo '
    
    ';
        //echo print_r($skill);
        echo wtf($skill);
    
        foreach($skill->professions as $p){
         echo '
    
    ';
         echo 'Profession Requirement - '.$p->name;
         echo '
    
    ';
        }
    }

    I tried to use with(‘professions’) when accessing skills with no luck as well. All other relationships set up the same way work fine. I checked all models for any type-o’s that were created because of my earlier error.

    Skill Relationships -

    class Skills extends Gas {
    
     public $table = 'skills';
    
     public $primary_key = 'id';
    
        public $relations = array(
           'has_many' => array('pets' => array('through' => 'skills_pets'),
                'races' => array('through' => 'skills_races'),
                'types' => array('through' => 'skills_types'),
                'professions' => array('through' => 'skills_professions'),
                'sets' => array('through' => 'skills_sets')
              )                                                                          
        );

    Professions Relationships -

    class Professions extends Gas {
    
     public $table = 'professions';
    
     public $primary_key = 'id';
    
        public $relations = array(
            'has_many' => array('skills' => array(
                       'through' => 'skills_professions',
                            )), 
        );

    Pivot Table Relationships -

    class Skills_professions extends Gas {
    
     public $table = 'skills_professions';
     
    
     public $primary_key = 'id';
    
        public $relations = array(
            'belongs_to' => array('skills' => array(),
                   'professions' => array()
                ), 
        );

     

  • #227 / Mar 10, 2012 11:31am

    toopay

    1583 posts

    In skills_professions table, do you have both skills_id and professions_id collumn(s) ? If you have the singular name, eg skill_id, you will also need to specify foreign_key option within your relationship definition.

  • #228 / Mar 10, 2012 2:06pm

    Khrome83

    22 posts

    I have the pivot table have a id field, skills_id and professions_id. Both plural. Its almost like something is being cached. I have several other relationship set up that work great. Is there a character limit for table or model names ir foreign keys?

  • #229 / Mar 10, 2012 6:29pm

    toopay

    1583 posts

    I forgot to ask this at the first place, what error message you receive? any PHP warning/error occurs?

    Is there a character limit for table or model names ir foreign keys?

    There is no character limit.

    The caching mechanism, within this ORM, is only to cache recorder(contain Query Builder params), and its result. It will serve same recorder request(which validated by it’s hash signature), until some write operation that touch those tables occurs(either save or delete).

    If you have other same type relationship working, i will suspect that theres something need to be correctly set up in your relationship property.

  • #230 / Mar 14, 2012 8:07pm

    DerLola

    12 posts

    I checked out your ORM today after trying DM and PHP AR and I must say that I love it. In my tests it was about 4 times faster than DM which is great. One feature I’m missing is a to_regular_object() method so I can use it directly in my templates. I’m considering writing an extension myself. Also, when will you release the 2.0 version? The namespacing feature would come in handy 😊

  • #231 / Mar 15, 2012 11:10am

    toopay

    1583 posts

    DerLola, the v2.0 is ready. Is just that the documentation needs some work, to cover this version. Hope could manage it, this week.

  • #232 / Mar 15, 2012 4:11pm

    DerLola

    12 posts

    That would be awesome. I just checked the 2.0 source on Github and it looks really nice and well structured. So maybe just a “what’s changed since 1.6” readme will do.

  • #233 / Mar 16, 2012 11:38pm

    toopay

    1583 posts

    @all,

    Just let you all know, v 2.0 was released. Please put your question, issue or anything related with those new version, in this thread.

  • #234 / Apr 01, 2012 1:20pm

    fountainhead

    10 posts

    Hi,

    I was using v1.4.3 and just saw that v2.1 of Gas ORM has released.
    From the documentation it looks like everything has changed.

    For ex. I earlier had

    class Property extends Gas {
    public $table = 'default_str_properties';
    public $primary_key = 'id';

    }

    Now I need to do something completely different?

    <?php namespace Model;

    use \Gas\Core;
    use \Gas\ORM;

    class Property extends ORM {

    function _init()
    {
    // Relationship definition

    // Field definition
    }

    }

    Is that correct? Do I need to rewrite my entire codebase again! :(

  • #235 / Apr 02, 2012 5:23am

    toopay

    1583 posts

    I was using v1.4.3 and just saw that v2.1 of Gas ORM has released.
    From the documentation it looks like everything has changed.
    ...
    Is that correct? Do I need to rewrite my entire codebase again! :(

    Version changed from 1.x.x to 2.x.x means there is major changes. However, the API was not too much changed.

    Yes, if you want to upgrade your Gas ORM then you will need to rewrite some part of your application to reflect the change. Consider whether you really need an upgrade or not. Version 1.4.X is stable enough, so unless you have some issue on it, and your application did not need key features of version 2.xx, just use the old version 😊

  • #236 / Apr 04, 2012 2:46am

    fountainhead

    10 posts

    Thanks Toopay.

    One question, I have a table call “properties” that is linked to “states” every property belongs to a state.

    $properties->with(‘states’)->all(); //Works just fine

    I want to do this filtering.

    $properties->with(‘states’)->find_where_states_state_name(‘AZ’) // Here state_name is a column in the states table

    Is there a way I can do that via chaining? I am new to Gas ORM and tried lots of combinations I know of :(

    Please advise.

  • #237 / Apr 04, 2012 7:00am

    toopay

    1583 posts

    @fountainhead, if you eager load some related entity, you can’t adding WHERE clause. Every related entity records is bound to parent entity by some unique identifier (PK and FK).

    This applied both in v1.xx and v.2.xx, but version 2.x provide several other clauses (select, order_by and limit).

    If you need some customized query, use CI query builder inside your model.

  • #238 / Apr 07, 2012 5:14am

    werchter

    3 posts

    Is it correct that in version 2.xx there is no ‘find_where’ anymore?
    If true, that’s really a dealbreaker for me! I really liked the fact I could use ActiveRecord conditions to query GAS models in version 1.xx….

    Update:
    Nevermind, I see I can still use 😊

    ->where(array( ... )).

     

  • #239 / Apr 07, 2012 12:29pm

    fountainhead

    10 posts

    I have just started using Gas ORM v1.4.3 .... and just wondering .... is there any advantage or disadvantage of using Datamapper over Gas ORM?

    Both of them seem fairly neat, but just wondering if I had to choose one ORM which should I go with?

    Just want to avoid discoveries later. I am not an expert in Code Igniter, so just want to avoid avoidable issues.

  • #240 / Apr 13, 2012 9:06am

    andriansandi

    5 posts

    Great libray, btw did Gas ORM compatible with HMVC system? As many my works used HMVC system.

    @andriansandi

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases