i have 2 Table
**Table sale :**
id_sale int
id_projet int
price float
date date
**Table sale_ligne:**
id_sale_ligne int
id_sale int FK_SALE
id_projet int
price float
date date
i was able to insert query on table line_sale at the same time when i insert on Sale table with
$this->dbAdapter->query('INSERT INTO sale (price, date) VALUES (?, ?)', array('price', 'date'));
$salesId = $this->dbAdapter->getDriver()->getLastGeneratedValue();
$this->dbAdapter->query('INSERT INTO sale_ligne (price, date, id_sale) VALUES (?,?,?)',array('price', 'date', $salesId));
, i want to (delete , update ) the line_sale row with relation with sale table with one click , i mean when i delete the sale recorde with (id=2 "exemple") the line_sale with (id_sale=2) will be deleted automaticly , same thinck for update when i update (price , date ) for record with (id=2 "exemple") they will be updated automaticly on line_sale with (id_sale=2) i m using adapter for sql request and i use this function to get the Line_sale's for a specific Sale
public function getLigneVenteByVente($id)
{
$result = $this->select(function (Select $select) use ($id){
$select->where(array('id_sale'=>$id));
$select->join('sale', ' ligne_sale.id_sale=sale.id ');
});
return $result;
}
Thx