Hello everyone, In codeigniter 3.1.0, using the pg_query tool, I call the PostgreSQL 9.3 function with a two-dimensional array transfer

Array ( [1] => 18 [5] => 20 [3] => 333333 ) 

where keys are an integer and the value can be an integer or a string

I passed it all as a two-dimensional array of strings.

 select * from funcname( ARRAY [ ARRAY[ '1','18' ], ARRAY[ '5','20' ], ARRAY[ '3','333333' ] ] ) 

and accept as an array in a loop

 create or replace function funcname( IN p_attributes_list varchar(255)[][] ) returns int as ... FOREACH next_attribute_value IN ARRAY p_attribute_list LOOP 

I get 6 values ​​of next_attribute_value from an array, and not 3 pairs of a key => values ​​as I would like ... And how is it possible and can I pass an associative array and, if so, how and how can I process it on the server?

Thank!

    1 answer 1

    Found an opportunity to set a cycle with a step:

     FOR i IN REVERSE 10..1 BY 2 LOOP -- i will take on the values 10,8,6,4,2 within the loop END LOOP; 

    which can be adapted for my task - but not sure whether this is the best solution and whether it is not possible to transfer an associative array?