PDF application throwing array errors

I have PDF application that creates multiple pages with each page having data for given record, at the time it creates the page I need it to add log entry so i created simple insert statement.

If I happen to use id of the record in any way I get Error to string conversion error.

I am using I just make a call to show the data itshows correct value but considers this variable {data_id} an array

sc_exec_sql(“INSERT INTO tble(info, invoice_id, date) VALUES ({info}, ‘{data_id}’, NOW())”);

In the error it literely prints Array[0] in place of {data_id}

Update -

Doing var_dump({data_id}); show following -> “string(6)”

This is just crazy, I found 3 major bugs I have to spent hours troubleshooting in just two days coding. And I have to make insane convoluted solutions to go around them.