Skip to content
Advertisement

pg_insert(): Accepts only string key for values

I’ve got postgres table with an auto-incremental column, and attempting to insert data from PHP with pg_insert returns a string key error. How would I go about modifying this for the different datatypes?

JavaScript

Currently returns the following error:

JavaScript

A var_dump returns:

JavaScript

My Postgres table is made up of:

JavaScript

Advertisement

Answer

From the PHP manual:

pg_insert() inserts the values of assoc_array into the table specified by table_name.

That means you can’t use a numeric array, like you do over here: [0]=> float(1609941177697)

I wouldn’t use this function anyway, please check pg_query_params(), pg_query() and pg_prepare/pg_execute

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement