On Nov 10, 2007 3:23 PM, dandreta <[EMAIL PROTECTED]> wrote: > > Hi! > I have one table called products and another table called soldproducts > in my database. The table products has these fields:id, name. And the > table soldproducts:id, name, date. I have a view in products where > there is a product with its name and an input field where I introduce > a date. And I want that when I submit the data, a function in my > productscontroller moves this product, with its id and name and with > the introduced date, to a new record in the table soldproducts. How > can I do this function? > Thanks and regards >
Are you sure you've designed the DB schema properly? I've never seen anyone do it this way. Generally people have a products table, a stock column, and another table that holds the relationships (like a purchases table that links product ID, customer ID, qty and date). Anyway, to help answer your question, you could probably just get the product you're looking for using $this->Product->findById( $product_id ) and use that info to $this->SoldProduct->save( $data ). You would then use $this->Product->delete( $product_id ) to get rid of it. Again, check your DB design. - Gonzalo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
