wrote:
> In my controller I have the following action;
>
> function editqtyAction()
> {
> // Dissable view and layout.
> $this->_helper->viewRenderer->setNoRender();
> $this->_helper->layout()->disableLayout();
>
> if ($this->_request->isPost()) {
>
> // Get the parameters from request and store in an array.
> $nest_components_id =
> $this->_request->getPost('nest_components_id');
> $qty = $this->_request->getPost('qty');
> $data = array('qty' => $qty);
>
> // Push to the database.
> $model = new Titanium_Model_NestComponents;
> $where = 'nest_components_id = ' . $nest_components_id;
> $id = $model->update($data, $where);
> echo(qty);
> }
> }
>
> However, I get a 500 internal server error. From the stack trace I can see the
> SQL generated is;
>
> "UPDATE `nest_components` SET `qty` = ?, `modified_date` = ?, `modified_by_id`
> = ? WHERE (id=)"
>
> So it looks like the WHERE clause is incorrect. I don't understand where the
> (id=) part is coming from, and why has it not used the where clause I
> specified?
>
>
> Steve
>
Steve,
Hi. You might want to re-write part of this to something like this I think,
which might work:
$where = $model->getAdapter()->quoteInto('nest_components_id = ?',
$nest_components_id);
$numOfRowsUpdated = $model->update($data, $where);
Note that the result from $model->update is not a $id as you've written but
rather how many rows were updated by the query.
Also, FYI, if your model is extending Zend_Db_Table_Abstract and
nest_components_id is your primary key on the NestComponents table then you
may find it to declare your own primary key in your sub-class by over-riding
$_primary, thus:
protected $_primary = 'nest_components_id';
otherwise the default 'id' is assumed to be the primary key (I think).
Regards,
Narinder.
--
______________________________________________________
| Narinder Chandi, Director,
| ToolBox Systems Limited, Surrey, England, UK.
| tel : +44 (0)1372 720117, mob : +44 (0)7973 512495
| www : http://www.toolbox.uk.com
| Skype : NarinderChandi
| LinkedIn : http://www.linkedin.com/in/toolboxsystems
| Twitter : @ToolBoxSystems
|______________________________________________________
| Consultancy * Development * Support
|______________________________________________________
没有评论:
发表评论