Welcome Guest, Not a member yet? Register   Sign In
Gas ORM
#61

[eluser]fountainhead[/eluser]
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.
#62

[eluser]andriansandi[/eluser]
Great libray, btw did Gas ORM compatible with HMVC system? As many my works used HMVC system.

@andriansandi
#63

[eluser]toopay[/eluser]
@sandhee_tube, you may consider use this solution for wiredesigz's HMVC integration.
#64

[eluser]fountainhead[/eluser]
Hi Toopay,

What does this mean?

"Unique fields is non-uniformal validation rule, and by doing this way, we doesnt pollute our above fields datatype definition."

I did this in my gas model:

$this->_unique_fields = array('email', 'username');

but somehow, there are no validation errors that get generated if I enter the same email id again.

I can do a hook but just wondering if you have something built into Gas ORM already?
#65

[eluser]toopay[/eluser]
@fountainhead,
I've just run unit test for version 1.4.3 and it works well.

This is typical save process, you can try :
Code:
// Use factory method, instead instantiate it like :
//    $new_user = new User();
$new_user = Gas::factory('user');

// Assume you already put the new entries data into $data variable
$new_user->fill($data);

// Dont forget to pass TRUE
if ($new_user->save(TRUE))
{
   echo 'success';
}
else
{
   echo 'fails';

   // Here you should see the validation error,
   // if you already set unique fields in your model
   var_dump($new_user->errors);
}

#66

[eluser]fountainhead[/eluser]
Thanks Toopay. Realize it works but just doesn't show up in
<?php echo validation_errors(); ?>

Not related to Gas ORM, but is there a way I can have them transfer the messages from $new_user->errors to form validation so that I can use <?php echo validation_errors(); ?>
#67

[eluser]toopay[/eluser]
@fountainhead,

You can extend CI form validation. Create file on application/libraries/MY_Form_validation.php contain something like :
Code:
<?php

class MY_Form_validation extends CI_Form_validation {

   public function set_gas_error($errors = array())
   {
      $this->_error_array = array_merge($errors, $this->_error_array);
   }

}
Then from my previous example, you can assign the errors :
Code:
$this->form_validation->set_gas_error($new_user->errors);
This way if you echoing validation_errors in your view, the errors within your gas model will be included.
#68

[eluser]fountainhead[/eluser]
Hi ... sorry basic question

I have a table called "pin" and every pin has one or zero "file"

My pin model is as follows:
Code:
class Gas_pin extends Gas {
    public $table = 'default_str_gas_pins';
    public $primary_key = 'id';

    // Every Gas_pin has a file
public $relations = array('has_one' => array('file' => array('foreign_key'=>'pin_image_1')));
}

My "file" model is as follows
Code:
class file extends Gas {
    public $table = 'default_files';
    public $primary_key = 'id';
}

My "pin" table has a field called "pin_image_1" which links up with the "file" table ...

I am unable to get the relationship working ...

I want to do:
Code:
$pin = new Gas_pin();
        $pins = $pin->with('file')->all();

I get the following error:
Model gas_pin located, but missing relationship properties.

Please help!
#69

[eluser]toopay[/eluser]
@fountainhead,

The error message that raised, should give you a clear idea whats happened. When you set a relationship that did not follow Gas convention, you need to set it up on both model(s). Refer to Relationship section within doc for version 1.x.
#70

[eluser]fountainhead[/eluser]
Hi Toopay ... thanks ... I tried few more steps to make it work .....
I am having trouble how to do the custom overriding ..

Can you please help?

The following works:
Code:
class File extends Gas {
    public $table = 'default_files';
    public $primary_key = 'id';

public $relations = array(
       'has_many' => array('gas_pin' => array('foreign_table'=>'default_str_gas_pins', 'foreign_key'=>'pin_image_1')),
      );
}

Code:
class Gas_pin extends Gas {
    public $table = 'default_str_gas_pins';
    public $primary_key = 'id';

public $relations = array(
      'belongs_to' => array('file' => array('foreign_key'=>'pin_image_1')),
     );

}

But, I actually think belongs_to in the gas_pin is not correct ... how can I can modify gas_pin to has_one "file"?




Theme © iAndrew 2016 - Forum software by © MyBB