// Create the new object
$invoice = new Invoice();
// Get the data from the database - source row
// You can create the data array yourself if you already have the data
$invoiceRow = $invoice->fetchRow($invoice->select()->where('invoice_id = ?', 1));
// Convert the data to an array
$data = $invoiceRow->toArray();
// Unset the invoice_id which should be the primary key. This will allow the addition
// of the new row and the RDBMS will generate a new ID for the new row
unset($data('invoice_id');
// Create a new row in the table
$newInvoice = $invoice->createRow($data);
// Save the data
$newInvoice->save();
I hope this helps
Nikolaos
On Fri, Dec 5, 2008 at 01:07, SalamFall <salam@seneweb.com> wrote:
How do I a row to the same table? or duplicate a set of row based on a
criteria?
for example:
$invoice = new Invoice(); // where invoice is a table Model
$invoice_id = $invoice->insert($data);
--
View this message in context: http://www.nabble.com/How-do-I-a-row-to-the-same-table--or-duplicate-a-set-of-row-based-on-a-criteria-tp20848299p20848299.html
Sent from the Zend DB mailing list archive at Nabble.com.
--
The contents of this message may contain confidential or privileged information and is intended solely for the recipient(s). Use or distribution to and by any other party is not authorized. If you are not the intended recipient, copying, distribution or use of the contents of this information is prohibited.
没有评论:
发表评论