githinji84
Member
Guys,
I am trying to use php plugin to update a field in the database but I keep getting this error "TypeError: a is null" via firebug and the database is not updated. The structure of the table is as follows:
Table name = 'test'
Unique id = 'id'
field to update = 'test' (update with the current logged on user_id)
I have checked and re-checked my code but I think its correct. I have also tried to use var_dump() it does not work that well I also have an error there "SyntaxError: missing ) in parenthetical"
I have been on this for hours please help
Here is the code.
$app = JFactory::getApplication();
$ids = $app->input->get('ids', array(), 'array');
$user = JFactory::getUser();
$userid = $user->get('id');
foreach ($ids AS $myid)
{
$row = $model->getRow($myid);
$invoice_id = $row->test___id;
$query = $db->getQuery(true);
// Fields to update.
$fields = array( $db->quoteName('test') . ' = ' . $userid);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('id') . ' = 1');
$query->update($db->quoteName('test'))->set($fields)->where($conditions);
$db->setQuery($query);
$result = $db->execute();
}
I am trying to use php plugin to update a field in the database but I keep getting this error "TypeError: a is null" via firebug and the database is not updated. The structure of the table is as follows:
Table name = 'test'
Unique id = 'id'
field to update = 'test' (update with the current logged on user_id)
I have checked and re-checked my code but I think its correct. I have also tried to use var_dump() it does not work that well I also have an error there "SyntaxError: missing ) in parenthetical"
I have been on this for hours please help
Here is the code.
$app = JFactory::getApplication();
$ids = $app->input->get('ids', array(), 'array');
$user = JFactory::getUser();
$userid = $user->get('id');
foreach ($ids AS $myid)
{
$row = $model->getRow($myid);
$invoice_id = $row->test___id;
$query = $db->getQuery(true);
// Fields to update.
$fields = array( $db->quoteName('test') . ' = ' . $userid);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('id') . ' = 1');
$query->update($db->quoteName('test'))->set($fields)->where($conditions);
$db->setQuery($query);
$result = $db->execute();
}