i'm working with Agile Toolkit
i got a Model_Product
class Model_Product extends Model_Table {
public $table="product";
function init(){
parent::init();
$this->addField('name')->mandatory(true);
$this->addField('price')->mandatory(true)->type('money');
$this->addField('user_id')->refModel('Model_User')
->defaultValue($this->api->auth->get('id'));
//$this->hasOne('User',null,'email'); => send me an error message
}
}
and Model_User
class Model_User extends Model_Table {
public $table="user";
function init(){
parent::init();
$this->addField('first_name')->mandatory('Prénom nécesssaire');
$this->addField('last_name')->mandatory('Nom nécesssaire');
$this->addField('email')->mandatory('entrez un email valide');
$this->addField('nationality')->mandatory('nécessaire')->enum(array('FR','EN','US'));
$this->addField('birthday')->defaultValue(date('Y-m-d'))->type('date');
$this->addField('is_admin')->type('boolean');
$this->hasMany('Product','user_id');
}
I want to list on a User page all the products from one User
$q=$this->api->db->dsql();
$q->table('product')->where('product.user_id',$this->api->auth->model['id']);
$tab->add('GRID')->setModel($q);
Some way, I get it wrong because I get an error no mater how I try to filter my Model.