public function save(Article $article) { $articleData = array('art_name' => $article->getName(), 'art_desc' => $article->getDesc(), 'art_price' => $article->getPrice(), 'art_cat' => $article->getCat(), 'art_dispo' => $article->getDispo()); if ($article->getId()) { // The article has already been saved : update it $this->getDb()->update('t_article', $articleData, array('art_id' => $article->getId())); } else { // The article has never been saved : insert it $this->getDb()->insert('t_article', $articleData); // Get the id of the newly created article and set it on the entity. $id = $this->getDb()->lastInsertId(); $article->setId($id); } }