SQL not executing on LogicHook

Hey!
Im working on this logic hook within the Accounts Module, on an after_save. I have a custom module built, and i need to update a row with the custom module table when an account field switches to active. Running Suite 6.5

$hook_array['after_save'][] = Array(1, 'Update School Record', 'custom/modules/Accounts/customschoollogichook.php','SchoolUpdate', 'UpdateSchoolField');
class SchoolUpdate
{

    function UpdateSchoolField ( $bean, $event, $args ){
        if ($bean->account_status_c == 'Active Account' && !empty($bean->fetched_row) && $bean->fetched_row['account_status_c'] <> $bean->account_status_c) {
            global $db;
            $accountID = $bean->id;
            $sourceLead = $db->fetchOne("SELECT id FROM leads where account_id = '{$accountID}'");
            if (!empty($sourceLead)) {
                $db->query("UPDATE schools SET account_id1_c = '{$accountID}' where lead_id_c = '{$sourceLead}'");

Did confirm the logic hook is getting hit but the queries are not executing.

Thanks!!!

Hey

you can add logs like

				$GLOBALS['log']->fatal("Entering function or conditions met"); 

and check the suitecrm.log it the conditions are being met
Just looking at your code

is this how we use not equals in php isn’t it usually !=

shouldn’t it be like

'$sourceLead'

If your issue is not resolved you can also log the query that is being executed

1 Like

no good on the Operators changes nor removing the brackets. D:
I’ll try adding a log.
Is there any restrictions on making select/update statements off others tables besides Accounts which the logic hook is under?

No there is no restrictions on any queries you want to run

update - issue solved!!
After checking the logs, the sql queries were returning as arrays
a simple implode() fixed this issue!
Thanks everyone!