/** * @param int $id * @return Product */ public function retCreatedProduct($id = 0) { $product = new Product(); $product->setId($id); $userRepository = new ProductRepository($product); $product->setRepository($userRepository); $data = $product->getRepository()->getProductDataById($id); foreach ($data[0] as $identifier => $value) { $func = 'set' . ucfirst($identifier); $product->{$func}($value); } return $product; }
public function updateProduct($id) { $sql = "update Product set name=':name', owner=':owner' where id=:id"; $this->db->execute($sql, array('id' => $id, 'name' => $this->product->getName(), 'owner' => $this->product->getOwner())); }