Hi,
adding to that, working with arrays in Kamailio is not really simple.
If in your database you have the following values:
key1 => value1
key1 => value2
key1 => value3
and have set those rows with an array type, the htable will look like
this after startup:
$sht(htableName=>key1[0]) == "value1"
$sht(htableName=>key1[1]) == "value2"
$sht(htableName=>key1[2]) == "value3"
$sht(htableName=>key1::size) == 3
Now you can use the size helper variable and iterate over those array
entries. So far so good. The bad comes when manipulating those
entries. Suppose you want to delete value2 from your htable. After you
did that, the key1[1] entry will just be missing, you'll have a hole
in your numbering, and the size counter will still be at three. And if
you then want to add another entry to the htable, you will have to
find out the next free key number (3) yourself, and you will have to
incement the size helper variable manually.
And to make it worse, when writing back the htable on shutdown, those
array type rows in database will end up as regular entries having
key1[0] etc as key. The size helper row will be written into database,
too.
So my recommendation would be to use the array stuff only on readonly
htables, but never on htables you manipulate inside Kamailio. There's
just too much that you have to think about.
Best Regards,
Sebastian
On Wed, Aug 30, 2017 at 9:04 PM, Daniel-Constantin Mierla
<miconda(a)gmail.com> wrote:
Hello,
can you try with a single value column?
The array type is something that was supposed to help keeping keys simpler
in database, but the key is concatenated with the index, is not really an
array.
Cheers,
Daniel
On 30.08.17 20:06, George Diamantopoulos wrote:
Hello all, I'm becoming a regular here now, aren't I?
So I have this table in mysql:
+----------+----------+--------+-----------+---------+
| key_name | key_type | value1 | value2 | value3 |
+----------+----------+--------+--------+--------+
| key1 | 1 | valueA | valueF | valueK |
| key1 | 1 | valueB | valueG | valueL |
| key1 | 1 | valueC | valueH | valueM |
| key2 | 1 | valueD | valueI | valueN |
| key2 | 1 | valueE | valueJ | valueO |
I was hoping I could have all this information available in an sht, where
for example:
$sht(a=>$key1[0]), $sht(a=>$key1[1]), etc
would return:
"valueA,valueF,valueK", "valueB,valueG,valueL" etc
but I can't figure out how to setup htable to import this data on restart. I
have tried various combinations of module parameters such as:
modparam("htable", "htable",
'my_htable=>size=8;autoexpire=86400;dbtable=my_table;cols="key_name,value1,value2,value3";'
I'm either getting errors, or dumping htable will only show one of the value
sets (key_type is not set to array).
Does anyone have a working config to share? Thanks!
George
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users(a)lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
www.twitter.com/miconda --
www.linkedin.com/in/miconda
Kamailio Advanced Training -
www.asipto.com
Kamailio World Conference -
www.kamailioworld.com