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) im 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
You can just use sql join or and like this:
DELETE FROM table1, table2 WHERE table1.id = (constant) AND table1.id = table2.id
Where constant is the id value that you want to delete form both table.
This has been answered in this question already by the way.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.