paulknox
New Member
I've been working my way through the wiki and am banging my head on this simple issue. I have a form that on submission I want it to reduce a stock number in a separate list.
The 'stock' list has 'lens_model' and 'stock_level' and the submitting form 'iol' has 'lens_model' the lens models are radio buttons.
The following code reduces the number of ALL lens models
$stock_lens_model = (array) $formModel->formData['iol___lens_model'];
// Get the db and the query
$db = JFactory::getDbo();
$query = $db->getQuery(true);
{
// Clear down any previous query
$query->clear();
// Update the query to decrease the value contained in the field "spaces" by 1 for the current course id.
$query->update('stock_levels')->set('stock_level = stock_level - 1')->where('lens_model ='. (int) $stock_lens_model);
$db->setQuery($query);
$db->execute();
}
So I tried using the raw and nothing happens..
$radio1 = (int) $formModel->formData['iol___lens_model_raw'];
// Get the db and the query
$db = JFactory::getDbo();
$query = $db->getQuery(true);
{
// Clear down any previous query
$query->clear();
// Update the query to decrease the value contained in the field "spaces" by 1 for the current course id.
$query->update('stock_levels')->set('stock_level = stock_level - 1')->where('lens_model ='. (int) $radio1);
$db->setQuery($query);
$db->execute();
}
Any suggestions would be appreciates!
The 'stock' list has 'lens_model' and 'stock_level' and the submitting form 'iol' has 'lens_model' the lens models are radio buttons.
The following code reduces the number of ALL lens models
$stock_lens_model = (array) $formModel->formData['iol___lens_model'];
// Get the db and the query
$db = JFactory::getDbo();
$query = $db->getQuery(true);
{
// Clear down any previous query
$query->clear();
// Update the query to decrease the value contained in the field "spaces" by 1 for the current course id.
$query->update('stock_levels')->set('stock_level = stock_level - 1')->where('lens_model ='. (int) $stock_lens_model);
$db->setQuery($query);
$db->execute();
}
So I tried using the raw and nothing happens..
$radio1 = (int) $formModel->formData['iol___lens_model_raw'];
// Get the db and the query
$db = JFactory::getDbo();
$query = $db->getQuery(true);
{
// Clear down any previous query
$query->clear();
// Update the query to decrease the value contained in the field "spaces" by 1 for the current course id.
$query->update('stock_levels')->set('stock_level = stock_level - 1')->where('lens_model ='. (int) $radio1);
$db->setQuery($query);
$db->execute();
}
Any suggestions would be appreciates!