creatoro/jelly — Issue #96: ManyToMany on unsaved models
Author: ivank
Created: 2011-11-09 14:15:17+00:00
State: open

When I do a $model->as_array() on an model that has not yet been created, I get an exception form here

``` php
public function get($model, $value)
{
if ($model->changed($this->name))
{
return Jelly::query($this->foreign['model'])
->where($this->foreign['field'], 'IN', $value);
}

// Set columns
$join_col1 = $this->through['model'].'.'.$this->through['fields'][1];
$join_col2 = $this->foreign['model'].'.'.$this->foreign['field'];
$where_col = $this->through['model'].'.'.$this->through['fields'][0];

// If the value hasn't changed, we need to pull from the database
return Jelly::query($this->foreign['model'])
->join($this->through['model'])
->on($join_col1, '=', $join_col2)
->where($where_col, '=', $model->id());
}
```

The thing is - value is null so the ``>where($this->foreign['field'], 'IN', $value);`` fails
There should be a empty($value) check here i think.