Friday, October 3, 2008

Add user_id from session to db when adding a product

Hi, I am busy reworking a bakesale script based on cake, my OOP php is
not that good. Maybe someone can point me here in the right direction.
I want to change a script the add a product and in sert in the db the
user_id in the product table - which should come from the User.id

function admin_add($category_id = 0) {
if(isset($this->data['Product'])) {
$this->redirect(array('action' => 'edit', 'id' => $this-
>Product->bsAdd($this->data)));
} else {
$this->set('data', $this->Category->read(null, $category_id));
}
}

function bsAdd($data = array()) {
$this->create();
$this->data = $data;
$this->save($this->data);
return $this->getLastInsertID();
}

Any help will be most greatful !!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: