Hi,
PS : how can i add code block ? this view is terrible for you i know....
i try to use Relationship models, i haven't error but i don't know how it's work. (sorry for my bad english.
here my models
class Composant extends Model
{
protected $ID_Composant;
protected $ID_Section;
protected $ID_Montant;
protected $ID_Remplissage;
public function initialize()
{
$this->belongsTo(
'ID_Section',
'Section',
'ID_Section'
);
$this->belongsTo(
'ID_Montant',
'Montant',
'ID_Montant'
);
$this->belongsTo(
'ID_Remplissage',
'Remplissage',
'ID_Remplissage'
);
}
public function __get($name)
{
if (property_exists($this,$name))
{
return $this->$name;
}
}
public function __set($name, $value)
{
if (property_exists($this,$name))
{
$this->$name = $value;
}
}
}
class Remplissage extends Model
{
protected $ID_Remplissage;
protected $Remplissage;
protected $Visserie;
protected $Panneaux;
protected $PrixHT;
protected $PrixTTC;
public function initialize()
{
$this->hasMany(
'ID_Remplissage',
'Composant',
'ID_Remplissage'
);
}
public function __get($name)
{
if (property_exists($this,$name))
{
return $this->$name;
}
}
public function __set($name, $value)
{
if (property_exists($this,$name))
{
$this->$name = $value;
}
}
}
class Montant extends Model
{
protected $ID_Montant;
protected $Hauteur;
protected $Largeur;
protected $Epaisseur;
protected $PrixHT;
protected $PrixTTC;
public function initialize()
{
$this->hasMany(
'ID_Montant',
'Composant',
'ID_Montant'
);
}
public function __get($name)
{
if (property_exists($this,$name))
{
return $this->$name;
}
}
public function __set($name, $value)
{
if (property_exists($this,$name))
{
$this->$name = $value;
}
}
}
class Section extends Model
{
protected $ID_Section;
protected $Lisses;
protected $Contrefort;
protected $SabotAssemblage;
protected $Goujons;
protected $Supports;
protected $PrixHT;
protected $PrixTTC;
public function initialize()
{
$this->hasMany(
'ID_Section',
'Composant',
'ID_Section'
);
}
public function __get($name)
{
if (property_exists($this,$name))
{
return $this->$name;
}
}
public function __set($name, $value)
{
if (property_exists($this,$name))
{
$this->$name = $value;
}
}
}
And my controller :
$composant = new Composant();
$result = $composant->findFirst();
$montant = $result->Montant;
$result has all ID to 1 (it's normal) but $montant is equal to NULL, don't know why. Can you explain me ?