I am still working on converting over to Gas ORM 2.0.
I came across a issue that I was hoping to get more information on. In the old version of gas, when Auto Generating models, the fields support ENUM, while the new version does not. Do I need to convert these myself to ENUM of type string.
Old Auto Generated Fields
'id' => Gas::field('auto[16]', array(), ''),
'name' => Gas::field('char[64]', array('required'), ''),
'description' => Gas::field('string', array(), ''),
'recast' => Gas::field('int[3]', array(), ''),
'activation_time' => Gas::field('int[2]', array(), ''),
'activation_type' => Gas::field('string', array(), 'ENUM'),
'skill_points' => Gas::field('int[3]', array(), ''),
'slot' => Gas::field('string', array(), 'ENUM'),
'chain' => Gas::field('string', array(), 'ENUM'),
'created' => Gas::field('datetime', array(), 'TIMESTAMP'),
'updated' => Gas::field('datetime', array(), 'TIMESTAMP'),
New Generated Fields
'id' => ORM::field('auto[16]'),
'name' => ORM::field('char[64]'),
'description' => ORM::field('string'),
'recast' => ORM::field('auto[3]'),
'activation_time' => ORM::field('auto[2]'),
'activation_type' => ORM::field('string'),
'skill_points' => ORM::field('auto[3]'),
'slot' => ORM::field('string'),
'chain' => ORM::field('string'),
'created' => ORM::field('datetime'),
'updated' => ORM::field('datetime'),
I am assuming in the case of Slot, I would convert this too -
'slot' => ORM:: field('string', array(), 'ENUM'),
The other thing to note, is that for ‘recast’, ‘skill_points’, ‘activation_time’ it has them set to AUTO as opposed to INT, even tough they are in in DB without the Auto Increment flag associated with them.
Additionally, before Gas ORM 2.0 I was using -
private $_types;
function set_types($types) {
$this->_types = array('types_id' => $types);
return $this;
}
function _after_save() {
if ($this->empty) {
// Record ID
$id = $this->last_id();
// _types
if(is_array($this->_types)){
$this->_types['skills_id'] = $id;
$this->db()->insert('skills_types', $this->_types);
}
}
}
I am guessing most of this will still work, but maybe I need to convert the insertion to -
if(is_array($this->_types)){
$nr = new Model\Skills\Types();
$nr->skills_id = $id;
$nr->types_id = _sets['types_id'];
$nr->save();
}
or
if(is_array($this->_types)){
$this->_types['skill_id'] = $id;
Model\Skills\Types::make($this->_types)->save(TRUE);
}
Is there a better way when inserting data with a pivot table?
In this situation I have a one-to-many relationship with skills = types.
So I am updating skills and want to specify the type for it, which goes through the pivot table skills_types, is there a better way?