$GLOBALS["db"]->query()  not working in before save logic hook

Hi

  I want to execute an sql statement in the before save logic hook.

I have tried

$GLOBALS['db']->query("UPDATE users SET description='test' WHERE id='27283e5a-8f34-b846-367a-561fbbb4cb54'");

$db = DBManagerFactory::getInstance();

$res = $db->query("UPDATE users SET description='test' WHERE id='27283e5a-8f34-b846-367a-561fbbb4cb54'");

But it is not working.Shijin Krishna@

Parents Reply
  • Hi Roman and Gustav

         I am currently work in on sugarcrm version 7.6.I have used

    class logic_hooks_class{

         function before_save_method($bean, $event, $arguments){

                        $user= BeanFactory::getBean('users', '27283e5a-8f34-b846-367a-561fbbb4cb54');

                        $user->description = 'Test';

                        $user->save();//line 8

                }

    But this was throwing

    Fatal error: Call to undefined method stdClass::save() in /<>/custom/modules/Users/logic_hooks_class.php on line 8

Children